How to implement two way databinding in windows form c#

suppose my win form has textboxes, listbox, dropdown, radio button and check box. now i want to bind those control and whenever data will be changes from out side then change should be reflected in control level. how to achieve it in winform. help me with
a small working sample code. thanks

Hello,
If using SQL-Server look at using SQL Dependency class to get notified of changes outside of your application say by another app or from even SQL Server Management Studio
https://www.google.com/search?q=sqldependency+example&sourceid=ie7&rls=com.microsoft:en-US:IE-SearchBox&ie=&oe=&rlz=&safe=active&gws_rd=ssl
Sorry I don't have a working example but perhaps the following might provide a clue into what is needed. I am only using a DataGridView but this could be expanded to other controls. There is a good deal of preparation and work internally to have this working
right when considering all scenarios
Form code
namespace FrontEnd_CS
/// <summary>
/// Provides the basics to listen to a database table operations, see also the
/// Readme file in the Solution Items
/// </summary>
/// <remarks>
/// DgvFilterManager is a third party component that permits right-click a column header
/// in a DataGridView and do filtering on one or more columns
/// </remarks>
public partial class Form1 : Form
private BindingSource bs = new BindingSource();
private Customers CustomerData = null;
public Form1()
InitializeComponent();
try
SqlClientPermission perm = new SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted);
perm.Demand();
catch
throw new ApplicationException("No permission");
public void OnNewMessageFromServer()
ISynchronizeInvoke iSyncInvoke = (ISynchronizeInvoke)this;
// Check if the event was generated from another thread and needs invoke instead
if (iSyncInvoke.InvokeRequired)
Customers.NewMessage messageDelegate = new Customers.NewMessage(OnNewMessageFromServer);
iSyncInvoke.BeginInvoke(messageDelegate, null);
return;
// If not coming from a seperate thread we can access the Windows form controls
LoadCurrentData();
private void LoadCurrentData()
DataGridView1.DataSource = null;
bs.DataSource = CustomerData.GetMessages();
DataGridView1.DataSource = bs;
DataGridView1.ExpandColumns();
bindingNavigator1.BindingSource = bs;
private void Form1_Load(object sender, EventArgs e)
CustomerData = new Customers();
CustomerData.OnNewMessage += OnNewMessageFromServer;
LoadCurrentData();
Support code
namespace BackEnd_CS
public class Customers
private static string ConnectionString = "Server=.\\SQLEXPRESS;Trusted_Connection=True;Initial Catalog=CustomerDatabase";
private SqlConnection Connection = null;
public delegate void NewMessage();
public event NewMessage OnNewMessage;
public Customers()
// Stop an existing services on this connection string just be sure
SqlDependency.Stop(ConnectionString);
// Start the dependency, User must have -- SUBSCRIBE QUERY NOTIFICATIONS permission
// Database must also have SSB enabled -- ALTER DATABASE CustomerDatabase SET ENABLE_BROKER
SqlDependency.Start(ConnectionString);
// Create the connection
Connection = new SqlConnection(ConnectionString);
~Customers()
SqlDependency.Stop(ConnectionString);
/// <summary>
/// Retreive messages from database via conventional SQL statement
/// </summary>
/// <returns></returns>
/// <remarks></remarks>
public DataTable GetMessages()
DataTable dt = new DataTable();
try
// Create command
// Command must use two part names for tables
// SELECT <field> FROM dbo.Table rather than
// SELECT <field> FROM Table
// Do not use
// FROM [CustomerDatabase].[dbo].[Customer]
// Use
// FROM [dbo].[Customer]
// Query also can not use *, fields must be designated
SqlCommand cmd = new SqlCommand("SELECT [Identifier],[CompanyName],[ContactName],[ContactTitle] FROM [dbo].[Customer]", Connection);
// Clear any existing notifications
cmd.Notification = null;
// Create the dependency for this command
SqlDependency dependency = new SqlDependency(cmd);
// Add the event handler
dependency.OnChange += OnChange;
// Open the connection if necessary
if (Connection.State == ConnectionState.Closed)
Connection.Open();
// Get the messages
dt.Load(cmd.ExecuteReader(CommandBehavior.CloseConnection));
catch (Exception ex)
throw ex;
return dt;
/// <summary>
/// Handler for the SqlDependency OnChange event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnChange(object sender, SqlNotificationEventArgs e)
SqlDependency dependency = sender as SqlDependency;
// Notices are only a one shot deal so remove the existing one so a new one can be added
dependency.OnChange -= OnChange;
// Fire the event
if (OnNewMessage != null)
OnNewMessage();
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my webpage under my profile but do not reply to forum questions.

Similar Messages

  • How to implement 3 way handshake in TCP protocol

    I am a newbie to socket programming. Can any one suggest me how to implement 3 way handshake?

    Java comes with java.net including Socket and ServerSocket. On the Java level you use this higher-level API (or even URLConnection or HttpURLConnection) and do not have to worry about the TCP handshake. You have no access to that low level either.

  • Error in video training - Implementing two-way binding

    During the Video training for Implementing two-way binding you have a slight error.
    If you follow along with the video training the instructor misses the step of assigning the Value Object(DTO) as Bindable.
    The instructor goes from adding the "@" symbol to the bound selectedEmployee.salary to running the application and it runs fine. To do this in the code you need to add [Bindable] to the Value Object(DTO) Employee.
    <s:TextInput id="salaryInput"
                             text="@{selectedEmp.salary}"/>
    package valueObjects
        [Bindable]  <!-- missing adding this line to the Value Object before running  to get it to actually work -->
        public class Employee

    Can you please file a bug at http://bugs.adobe.com/flex/ and post the bug number here.
    Thanks,
    Peter

  • How to implement the spell check in oracle forms 10g or 6i...

    How to implement the spell check in oracle forms.
    Is there any different method is there.
    Please help me....
    Praveen.K

    Here is one different from Jspell..
    In 6i client/server you can call MS Word spell checker using OLE. Below sample code for 6i.
    For 10g you will need webutil to use same code. install webutil and just replace "OLE2." with "CLIENT_OLE2."
    PROCEDURE spell_check (item_name IN VARCHAR2)
    IS
       my_application   ole2.obj_type;
       my_documents     ole2.obj_type;
       my_document      ole2.obj_type;
       my_selection     ole2.obj_type;
       get_spell        ole2.obj_type;
       my_spell         ole2.obj_type;
       args             ole2.list_type;
       spell_checked    VARCHAR2 (4000);
       orig_text        VARCHAR2 (4000);
    BEGIN
       orig_text := NAME_IN (item_name);
       my_application := ole2.create_obj ('WORD.APPLICATION');
       ole2.set_property (my_application, 'VISIBLE', FALSE);
       my_documents := ole2.get_obj_property (my_application, 'DOCUMENTS');
       my_document := ole2.invoke_obj (my_documents, 'ADD');
       my_selection := ole2.get_obj_property (my_application, 'SELECTION');
       ole2.set_property (my_selection, 'TEXT', orig_text);
       get_spell :=ole2.get_obj_property (my_application, 'ACTIVEDOCUMENT');
       ole2.invoke (get_spell, 'CHECKSPELLING');
       ole2.invoke (my_selection, 'WholeStory');
       ole2.invoke (my_selection, 'Copy');
       spell_checked := ole2.get_char_property (my_selection, 'TEXT');
       spell_checked :=SUBSTR (REPLACE (spell_checked, CHR (13), CHR (10)),1,LENGTH (spell_checked));
       COPY (spell_checked, item_name);
       args := ole2.create_arglist;
       ole2.add_arg (args, 0);
       ole2.invoke (my_document, 'CLOSE', args);
       ole2.destroy_arglist (args);
       ole2.RELEASE_OBJ (my_selection);
       ole2.RELEASE_OBJ (get_spell);
       ole2.RELEASE_OBJ (my_document);
       ole2.RELEASE_OBJ (my_documents);
       ole2.invoke (my_application, 'QUIT');
       ole2.RELEASE_OBJ (my_application);
    END;Call it like this: SPELL_CHECK ('BLOCK.MY_TEXT_ITEM' );

  • Implement two way replication on few tables

    Is there a way where I can implement 2 way replication.
    For instance I've two database A and B
    In a table in database A get updated or changed ..the effect should be shown on B
    and vice versa....
    Need ideas...

    * Oracle edition (enterprise, standard),
    Enterprise edition
    * network connectivity (is there a stable network link between the two),
    Yes we have a stable network
    * latency requirements (how quickly does a change on one have to appear on the other), and
    probably every 3 hrs
    * business requirements (why are you replicating the data in the first place)
    Well ours is call center, we work according to the availability of the interpereters and also we keep change pricing of call on daily basis.
    So there are few tables which needed to be updated regularly.

  • How to implements two interface?

    i have a applet to implement two interface,the actionlistener and the appletcontext.how to do it??
    Thank You!

    with a comma

  • How to implement iview for gui of windows ?

    Hi all.
    We are implementing the single sign on, integrate with EP with SAP R/3.
    We create ivew for gui of windows.
    When we sign in the EP, we click on the iview, inside iview, there is a window gui of sap gui.
    Now we meet with the error ' Issuer of SSO ticket is not authorized.
    We want to how to implement it using ticket authoration method. Whats the detailed steps ?
    Thanks a lot, its very urgent.

    Basically you need to logon as Administrator
    Go to ->System Administration -> System Configuration -> Keystore Administration -> Download veryfy.der
    then
    Check backend parameters...
    login/accept_sso2_ticket = 1
    login/create_sso2_ticket = 2
    Logon to Backend, go to transaccion strustsso2 and add the certificate (veryfy.der)
    At the portal, go to ->System Administration -> System Configuration -> System Lanscape -> go to the system and make sure that Logon Method is SAPLOGONTICKET
    That should be pretty much it...
    Hope this help!
    Juan Reyes

  • How to implement a java class in my form .

    Hi All ,
    I'm trying to create a Button or a Bean Area Item and Implement a class to it on the ( IMPLEMENTATION CLASS ) property such as ( oracle.forms.demos.RoundedButton ) class . but it doesn't work ... please tell me how to implement such a class to my button .
    Thanx a lot for your help.
    AIN
    null

    hi [email protected]
    tell me my friend .. how can i extend
    the standard Forms button in Java ? ... what is the tool for that ... can you explain more please .. or can you give me a full example ... i don't have any expereience on that .. i'm waiting for your reply .
    Thanx a lot for your cooperation .
    Ali
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by [email protected]:
    Henrik, the Java importer lets you call Java classes on the app server side - I think what Ali is trying to do is integrate on the client side.
    If you want to add your own button then if you extend the standard Forms button in Java and then use this class name in the implementation class property then the Java for your button will be used instead of the standard Forms button. And since it has extended the basic Forms button it has all the standard button functionality.
    There is a white paper on OTN about this and we have created a new white paper which will be out in a couple of months (I think).
    Regards
    Grant Ronald<HR></BLOCKQUOTE>
    null

  • How to embed the openGL console into windows form applicaion.

    I am using tao.framework in C# and I've done what I want in OpenGL using external window , but I want
    to integrate this window in windows form application. I created black window in form by using  simpleOpenGlControl1 in toolbox, but I dont know how can I integrate my code in this. I've attached my main method below.  Any help will be much appreciated.
    Thanks
    [STAThread]
    static void Main()
    Glut.glutInit();
    Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_RGB | Glut.GLUT_DEPTH);
    Glut.glutGetWindow();
    Glut.glutInitWindowSize(500, 500);
    Glut.glutInitWindowPosition(700, 100);
    Glut.glutCreateWindow("Lang Yuzer Robot Arm");
    Gl.glEnable(Gl.GL_COLOR_MATERIAL);
    Gl.glEnable(Gl.GL_LIGHTING);
    Gl.glEnable(Gl.GL_LIGHT0);
    Gl.glEnable(Gl.GL_DEPTH_TEST);
    Gl.glEnable(Gl.GL_NORMALIZE);
    Gl.glEnable(Gl.GL_CULL_FACE);
    Glut.glutDisplayFunc(Form1.myDisplay);
    Glut.glutReshapeFunc(Form1.myReshape);
    Glut.glutIdleFunc(Form1.myIdle);
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new Form1());
    Glut.glutMainLoop();

    Please use the OpenTK forums for questions related to the OpenTK framework (formerly Tao.Framework).
    http://www.opentk.com/forum

  • How to implement two dependent dropdown lists in an input  table row?

    Hi all,
    I am new in Jdev 11g. I try to develop an input table with two dependent dropdown list. I can create independent dropdown list in such table. When I try to implement dependent one following some examples do it in a form using bind variable in the view object I get an empty listbox. How can I do this? Is it possible. I cannot find any documents about this.
    Thanks in advance

    Hi,
    it hasn't changed between 10.1.3 and 11. The basic outline of how you do it is
    - use a managed bean to query the data
    - populate the list with f:selectItems that point to the managed bean ArrayList<SelectItem> for the master and the detail
    - obtain the master ID in the managed bean by parsing the #{row} variable when the table renders
    - then bulild the detail list
    - have the detail list referencing the ArrayList<SelectItem> you expose for the details
    Note that without proper caching, the action is quite expensive
    Frank

  • How to implement two different websites with one section that has the same content?

    I have two sister websites, each for a separate but related department in a hospital. On each of these websites, I have a main tab called library, which has about 30 pages within it for related healthcare issues. The library is the exact same content on each site, but the main navigation and header for the site is obviously different. I have been upkeeping this identical content on both sites (if something is changed, then I have to do it twice). This isn't efficient and I would like to find a way to combine them somehow. I don't have a ton of experience but I catch on pretty quickly and I basically need ideas for the best way to handle this. I have considered creating a third site, and the library tab on each of the other sites would take you to this new site. I have also wondered if there is a way to embed duplicate content into two separate pages (maybe with an iframe). That way I would update the original file and it would be updated on both sites.
    The sites also have different body sizes. One is 960 pixels wide and the other is 690 because it has a sidebar that makes it smaller. How would you all recommend I handle this? I use Dreamweaver CS6 and my pages are all HTML

    I looked into Server Side Includes and I think I would like to try it, but I can't seem to get it working. The problem is both of my sites are under a separate domain but hosted the same way I believe. For instance, I have two dreamweaver sites, but when I use my FTP, I have one large folder for the main site, then the sister site is in a folder within the main site folder. Although you can get to the main site using www.ukneurology.com, you can also get to the site using kyneurosurgery.com/neurology/index.html. I think this is what is messing me up because I can't seem to get it to work right.

  • How is the best way to delete Windows off of your Mac?

    I have Windows all up and running, and I no longer need it. What is the best way to get rid of that partition, and be back ot pure OSX? I would love to hear there is a way without erasing my whole hard drive. Thanks!

    Here's the way. Pages 23 and 24
    Removing Windows Partition - restoring to a single partition
    It's for Beta 1.3 but that does not matter - the removal instructions have never changed.

  • In how many ways we can create new document and how to implements this ways?

    I found that we can create new document by 3 ways
    1)by using session object of application ,document list as follow
    InterfacePtr<IApplication> firstdoc(GetExecutionContextSession()->QueryApplication());
              InterfacePtr<IDocumentList> docList(firstdoc->QueryDocumentList());
      docList->NewDoc(25089,IDataBase::ProtectionLevel.kProtectSave, nil);
    but in this case i am not getting how to use newdoc method i.e which parameter we have to pass(not even clear from API reference )
    2)by using command
    InterfacePtr<IApplication> firstdoc(GetExecutionContextSession()->QueryApplication());
              InterfacePtr<IDocumentList> docList(firstdoc->QueryDocumentList());
      InterfacePtr<ICommand> new1(CmdUtils::CreateCommand(kNewDocCmdBoss));
              UIDList asd(docList);
              new1->SetItemList(asd);
              CmdUtils::ProcessCommand(new1);
    3)bu using some util or facade interface
    Utils<IDocumentCommands>()->New( . . .)
    in this case also  i am not geeting how to use new method 
    I try all this method but none of them working .i knew i am doing some mistake  in all these method so please correct me where i am wrong .
    Main problem is in the first parameter of newdoc method i.e what is class id how to use them 

    1. add to your project "SDKLayoutHelper.cpp", "SDKLayoutHelper.h"
    2. #include "SDKLayoutHelper.h"
    insert code:
    do{
             SDKLayoutHelper helper;
             UIDRef docRef = helper.CreateDocument();
             if (UIDRef::gNull == docRef)
                 break;
             helper.OpenLayoutWindow(docRef);
        }while(kFalse);
    Regards!

  • How can i two adobe digital edition windows?

    Is it possible to open two docs at the same time - strictly one document in two different windows ? I have to campare two parts of one document and it would be much easier if i can do it using two windows on my two monitors. Please help!

    Pertains to a Windows machine..
    Definitely get other opinions on this. I last did this myself in 2010.
    The most important thing, is to make sure you have an account (which I think you must have, or you probably couldn't have posted here).
    As I recall, I downloaded ADE to my new computer, launched the software, authorized the new computer by supplying my login, and then just moved the 'My Digital Editions' folder to the new machine.
    Be sure to de-authorize your old machine after you have done all of this, or over time you could end up exceeding your 'simultaneous devices'-limit for accessing your materials. I suspect that *from within the app itself, while it is still installed on your old machine* may be your only opportunity to do this. It is certainly the best/easiest.
    Hey Internet! Have you done this more recently than I? If so, please chime in to make corrections or add detail.

  • How to implement 2-way SSL in OSB web services

    Hi ,
    I need to implement secured SSL communication in my OSB web services . For this I have used the self signed certificates in weblogic console and configured them .
    I also enabled the https parameter in my proxy service but now when I am trying to open the proxy wsdl in browser it says unauthorised access.
    Even in SOAP UI when I am trying to access it says "Error loading wsdl" .
    Please help.

    Hi,
    Do you have created a Service Key provider and attached the same to proxy service.
    Oracle Service Bus verifies that you have associated a service key provider with the proxy service and that the service key provider contains a key-pair binding that can be used as a digital signature.
    Service Key Providers
    Regards,
    Abhinav

Maybe you are looking for