Windows Forms Simple Data Binding

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Empire City

    #1

    Windows Forms Simple Data Binding

    I have a screen:

    Email address: ------------
    Name: --------------
    Phone: ----------------

    Add, Change, Delete, Cancel, Exit

    When the user enters the email address and hits TAB in the
    EmailTextBox_Le ave method, I create and fill a DataSet with the single
    record. I then bind that record to the form controls as such:

    EmailTextBox.Da taBindings.Add ("Text", ds.Tables["Customers"], "Email");
    NameTextBox.Dat aBindings.Add(" Text", ds, "Customers.Name ");

    I setup a CurrencyManager to check the record count although it should
    always be one as the Email is unique:

    myCurrencyManag er =
    (CurrencyManage r)this.BindingC ontext[ds.Tables["Customers"]];
    if ( myCurrencyManag er.Count == 0) etc.

    I'm somewhat new at all this scope/DataSet stuff and I have a lot of best
    practices issues. If someone could point me to an example that would be
    nice.

    How would I setup the textbox to data element binding in the DataSet before
    I fill the DataSet? I guess it should be outside the scope of the
    EmailTextBox_Le ave method in the section where the
    "System.Windows .Forms.TextBox EmailTextBox" stuff is defined. Would I have
    to manually create the DataSet with all that AddColumn business and then
    bind it somehow before I actually filled the DataSet with the single record?
    Should I have a myCreateClass : DataSet method that uses a new instance
    inside the Leave method? How and where would I setup a get/set property to
    easily access a data element by myDataElement.v alue, etc.

    I like having the manual control of doing what I want in the bottom buttons,
    etc. so I don't think I'm looking for that generic generated thing that
    cycles next record type thing. Although next/previous could be nice
    fuctionality and if that's the best way to go fine. The CurrencyManager also
    has some nice events for record state changed, etc.

    I know in pre-oo days we would call what I'm looking for a 'standard' or
    best code example for this specific type of ACID (add, change, inquire,
    delete) function. Would the oo term be for this type of standard example for
    this type of function?


Working...