Loop through Controls?

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

    #1

    Loop through Controls?

    I have a form with several textboxes, checkboxes, and
    comboboxes that I want to dynamically databind to a
    column in the DataRow being passed in when the form is
    intantiated. I have named the fields the same as the
    column names that will hold the values. I am stuck.
    This is what I have so far. Please help.

    public AddPatientForm( DataRow PatientRecord )
    {
    InitializeCompo nent();

    //Fill with current record
    foreach(Control MyControl in this.Controls)
    {
    //this.FirstName. DataBindings.Ad d
    ("Text",Patient Record[1],null);
    }
    }
  • Tom

    #2
    Re: Loop through Controls?

    Use reflection.
    Tom Clement

    "Phill" <pshaw@proceedt ech.com> wrote in message
    news:05b901c37d 5c$55bc1a80$a30 1280a@phx.gbl.. .[color=blue]
    > I have a form with several textboxes, checkboxes, and
    > comboboxes that I want to dynamically databind to a
    > column in the DataRow being passed in when the form is
    > intantiated. I have named the fields the same as the
    > column names that will hold the values. I am stuck.
    > This is what I have so far. Please help.
    >
    > public AddPatientForm( DataRow PatientRecord )
    > {
    > InitializeCompo nent();
    >
    > //Fill with current record
    > foreach(Control MyControl in this.Controls)
    > {
    > //this.FirstName. DataBindings.Ad d
    > ("Text",Patient Record[1],null);
    > }
    > }[/color]


    Comment

    Working...