473,326 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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 )
{
InitializeComponent();

//Fill with current record
foreach(Control MyControl in this.Controls)
{
//this.FirstName.DataBindings.Add
("Text",PatientRecord[1],null);
}
}
Nov 15 '05 #1
1 1374
Tom
Use reflection.
Tom Clement

"Phill" <ps***@proceedtech.com> wrote in message
news:05****************************@phx.gbl...
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 )
{
InitializeComponent();

//Fill with current record
foreach(Control MyControl in this.Controls)
{
//this.FirstName.DataBindings.Add
("Text",PatientRecord[1],null);
}
}

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ryan Liu | last post by:
How to loop though controls on the form? I set each control's TabStop and TabIndex, but at run time, I press Tab key, it jump though first control to last control and does not go back to the...
4
by: David A. Beck | last post by:
Is there a way I can loop through a form object in ASP.NET codebehind like in VB.NET and get all of the controls?
4
by: Ryan Ternier | last post by:
Thanks for the previous help guys! I got my list box issue working, but now i'm trying to loop through all the items in my page. I want to find each listbox, once I do i strip the ID down to...
4
by: sck10 | last post by:
I changed my aspx page to use a master page. The problem is that I can no longer loop through the controls on the content page. My question is how do you loop through the controls on the master...
33
by: Brian | last post by:
I have a list of plain HTML radio buttons that I want to be able to loop through, get the values from them and insert them into a db. each one should be a separate record... Can anyone please give...
3
by: Kezza | last post by:
Hi There.. I have dynamically created some textbox and checkbox controls by adding them to a panel. Now I would like to get the values out. I have created a for each loop that I can see the...
8
by: dominique | last post by:
Hi, Is it possible (in vb.net with WinForms) to loop throw controls inside a container (form or panel) sorting the controls on a property (.tabindex for example) ? My problem : on several...
7
by: J L | last post by:
I need to loop through a form's controls collection and delete some based on type and location. I have tried For..Each and For i = 0 to form.controls.count - 1 but when I delete any it messes up...
10
by: Derek Hart | last post by:
I am going in circles trying to loop through properties on 3rd party controls. For example, I have a textbox that has its maximum length located at MyTextBox.Properties.MaxLength - instead of the...
9
tlhintoq
by: tlhintoq | last post by:
Situation: A Windows Form with a single User Control containing 4 custom controls. This lets me drop the User Control on its own form to make it a dialog, or make it part of a larger configuration...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.