What's the point of Simple Data Binding?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jow Blow

    #1

    What's the point of Simple Data Binding?


    Hello All,

    In two different books, Simple Data Binding to a control is explained
    with an example of a TextBox where the data is initialized with an
    array.

    For example a class is defined as such:

    public class Vendor
    {
    private string vendorName;
    public string VendorName
    {
    get
    {
    return vendorName;
    }
    set
    {
    vendorName = value;
    }
    }

    public Vendor(string strVendorName)
    {
    VendorName = strVendorName;
    }
    }
    }

    A TextBox is placed on the main form Form1 with the following code:

    public Vendor[] aVendors;

    private void Form1_Load(obje ct sender, System.EventArg s e)
    {
    this.aVendors = new Vendor[3];
    aVendors[0] = new Vendor("Microso ft");
    aVendors[1] = new Vendor("Praxis" );
    aVendors[2] = new Vendor("Rationa l");


    txtVendor.DataB indings.Add("Te xt",aVendors,"V endorName");
    }

    where txtVendor is the name of the TextBox.

    My question now is what else can you do with this? What's the point?
    Is there some utilitarian advantage here that I am not seeing?

    Neither of the texts expands on this. They both go into Complex Data
    Binding which is a different animal. FYI,I am coming from the MFC VC++
    world is that means anything.

    Thanks,
    Joe

    I can also be reached at:
    filter1_at_digi talchickenDOTne tNOSPAM
  • ClayB [Syncfusion]

    #2
    Re: What's the point of Simple Data Binding?

    Try adding a button to your form with this button handler.

    private void button1_Click(o bject sender, System.EventArg s e)
    {
    BindingManagerB ase bmb =
    this.BindingCon text[this.aVendors];
    bmb.Position = (bmb.Position + 1) % bmb.Count;
    }

    Then imagine your vendor class has 50 public properties, and you want to
    show 10 of them in labels or textboxes on a form so you can edit them. You
    could then use the BindingManagerB ase to move the 'current' vendor back and
    forth. This effectively lets you page through all the vendor' properties
    with just Next and Previous buttons.

    =============== ===========
    Clay Burch, .NET MVP

    Visit www.syncfusion.com for the coolest tools

    "Jow Blow" <see_address@in _msg.com> wrote in message
    news:eh8pvvc091 f3l2u4t6tsea4er 016jo6sbj@4ax.c om...[color=blue]
    >
    > Hello All,
    >
    > In two different books, Simple Data Binding to a control is explained
    > with an example of a TextBox where the data is initialized with an
    > array.
    >
    > For example a class is defined as such:
    >
    > public class Vendor
    > {
    > private string vendorName;
    > public string VendorName
    > {
    > get
    > {
    > return vendorName;
    > }
    > set
    > {
    > vendorName = value;
    > }
    > }
    >
    > public Vendor(string strVendorName)
    > {
    > VendorName = strVendorName;
    > }
    > }
    > }
    >
    > A TextBox is placed on the main form Form1 with the following code:
    >
    > public Vendor[] aVendors;
    >
    > private void Form1_Load(obje ct sender, System.EventArg s e)
    > {
    > this.aVendors = new Vendor[3];
    > aVendors[0] = new Vendor("Microso ft");
    > aVendors[1] = new Vendor("Praxis" );
    > aVendors[2] = new Vendor("Rationa l");
    >
    >
    > txtVendor.DataB indings.Add("Te xt",aVendors,"V endorName");
    > }
    >
    > where txtVendor is the name of the TextBox.
    >
    > My question now is what else can you do with this? What's the point?
    > Is there some utilitarian advantage here that I am not seeing?
    >
    > Neither of the texts expands on this. They both go into Complex Data
    > Binding which is a different animal. FYI,I am coming from the MFC VC++
    > world is that means anything.
    >
    > Thanks,
    > Joe
    >
    > I can also be reached at:
    > filter1_at_digi talchickenDOTne tNOSPAM[/color]


    Comment

    • Jow Blow

      #3
      Re: What's the point of Simple Data Binding?


      Clay,

      Thanks for your response.

      I can see your point.

      In VC++ MFC, one would use the DDX, the UpdateData() and so forth
      function in order to pass data from variables to controls or vice
      verse. The methodology in .NET doesn't seem to be as explicit... at
      least it isn't to me.

      I'm not seeing explicit ways to (as per the previous example):
      pass data from the control back to sVendors once data in aVendors has
      changed or the form is closing, AND
      refresh the control(s) once the base data has changed.

      Neither of the two books I have cite an example.

      Also neither show where currencymanager is used explicitly. Both speak
      of CurrencyManager in comments but show the Position property of
      BingingContext being used. As far as I can tell from the .NET
      documentation Position is being called from a BindingContext. I see no
      example where CurrencyManager is being called and I dont see an
      instance of it as a member of form classes or controlcontaine rs or
      bindingcontexts . I must be missing something.

      Thanks Clay...

      Joe


      On Thu, 8 Jan 2004 04:55:27 -0500, "ClayB [Syncfusion]" wrote:[color=blue]
      >Try adding a button to your form with this button handler.
      >
      > private void button1_Click(o bject sender, System.EventArg s e)
      > {
      > BindingManagerB ase bmb =
      >this.BindingCo ntext[this.aVendors];
      > bmb.Position = (bmb.Position + 1) % bmb.Count;
      > }
      >
      >Then imagine your vendor class has 50 public properties, and you want to
      >show 10 of them in labels or textboxes on a form so you can edit them. You
      >could then use the BindingManagerB ase to move the 'current' vendor back and
      >forth. This effectively lets you page through all the vendor' properties
      >with just Next and Previous buttons.
      >
      >============== ============
      >Clay Burch, .NET MVP
      >
      >Visit www.syncfusion.com for the coolest tools[/color]

      Comment

      • Jow Blow

        #4
        Re: What's the point of Simple Data Binding?

        On Fri, 09 Jan 2004 18:31:12 GMT, Jow Blow <see_address@in _msg.com>
        wrote:[color=blue]
        >I'm not seeing explicit ways to (as per the previous example):
        >pass data from the control back to sVendors once data in aVendors has
        >changed or the form is closing, AND
        >refresh the control(s) once the base data has changed.[/color]


        CORRECTION. That should be aVendors and not sVendors.

        Joe

        Comment

        Working...