Click here to Skip to main content
15,884,064 members
Home / Discussions / C#
   

C#

 
AnswerRe: To filter datagridview using like IN and NOT IN Pin
Shameel23-Feb-12 8:22
professionalShameel23-Feb-12 8:22 
GeneralRe: To filter datagridview using like IN and NOT IN Pin
Abhinav S23-Feb-12 0:00
Abhinav S23-Feb-12 0:00 
GeneralRe: To filter datagridview using like IN and NOT IN Pin
polachan23-Feb-12 0:13
polachan23-Feb-12 0:13 
AnswerRe: To filter datagridview using like IN and NOT IN Pin
polachan23-Feb-12 0:23
polachan23-Feb-12 0:23 
AnswerRe: To filter datagridview using like IN and NOT IN Pin
AntDC23-Feb-12 5:37
AntDC23-Feb-12 5:37 
QuestionOptions to check logical equivalence of Boolean expressions Pin
raj_2822-Feb-12 20:16
raj_2822-Feb-12 20:16 
AnswerRe: Options to check logical equivalence of Boolean expressions Pin
Abhinav S22-Feb-12 20:54
Abhinav S22-Feb-12 20:54 
QuestionHow can I to manipulate dynamically created controls? Pin
NWNewelll22-Feb-12 10:42
NWNewelll22-Feb-12 10:42 
Lets say I have a form where someone can catalog a multiple people's Name and their State and City?

Assume I already have all the State/Cities in database. (a table for each state, with cities listed in each table)

The Name field will be a TextBox. And the State & City fields will be ComboBox (DropDownLists).

One row (for the entry of one person) already exists in the form. But I want the user to be able to dynamically add rows of entries by pressing an "Add Person" button.

The next step is where I'm struggling. In each dynamically added row of fields, I would like the second ComboBox (Cities) to be populated depending on which State is chosen in the first Combo Box. Also, the Cities ComboBox will remain disabled until the State ComboBox is chosen.

My code looks something like this:

C#
public ComboBox cbState;
public ComboBox cbCities;
public static int NumberOfPeople = 1;


private void btnAddNewPerson_Click(object sender, EventArgs e)
{

    NumberOfPeople++;

    TextBox txtPerson = new TextBox();
    txtPerson.Name = "Person" + NumberOfPeople;
    Panel.Controls.Add(txtPerson);

    //  ADD State ComboBox
    cbState = new ComboBox();
    cbState.Name = "State" + NumberOfPeople;
    cbState.Enabled = true;
    cbState.DropDownStyle = ComboBoxStyle.DropDownList;
    Panel.Controls.Add(cbState);

    //  ADD City ComboBox
    cbCity = new ComboBox();
    cbCity.Name = "City" + NumberOfPeople;
    cbCity.DropDownStyle = ComboBoxStyle.DropDownList;
    cbCity.Enabled = false;
    cbCity.SelectedValueChanged += new System.EventHandler(this.ChangeState);
    Panel.Controls.Add(cbCity);

}

private void ChangeState(object sender, EventArgs e)
{

   ..... Don't know how to properly identify the dynamically created City ComboBox that is in the same row as the State ComboBox that was just changed, and manipulate/populate it.....

}


Anyone able to help me solve this issue??

I'd greatly appreciate it!!
AnswerRe: How can I to manipulate dynamically created controls? Pin
PIEBALDconsult22-Feb-12 11:04
mvePIEBALDconsult22-Feb-12 11:04 
AnswerRe: How can I to manipulate dynamically created controls? Pin
BobJanova22-Feb-12 22:57
BobJanova22-Feb-12 22:57 
AnswerRe: How can I to manipulate dynamically created controls? Pin
GParkings22-Feb-12 23:00
GParkings22-Feb-12 23:00 
AnswerRe: How can I to manipulate dynamically created controls? Pin
BillWoodruff24-Feb-12 15:00
professionalBillWoodruff24-Feb-12 15:00 
QuestionHow can we access to an object of a form from another form? Pin
Fred 3422-Feb-12 9:59
Fred 3422-Feb-12 9:59 
AnswerRe: How can we access to an object of a form from another form? Pin
PIEBALDconsult22-Feb-12 10:09
mvePIEBALDconsult22-Feb-12 10:09 
GeneralRe: How can we access to an object of a form from another form? Pin
Fred 3422-Feb-12 11:53
Fred 3422-Feb-12 11:53 
AnswerRe: How can we access to an object of a form from another form? Pin
Wes Aday22-Feb-12 10:32
professionalWes Aday22-Feb-12 10:32 
GeneralRe: How can we access to an object of a form from another form? Pin
Fred 3422-Feb-12 11:51
Fred 3422-Feb-12 11:51 
AnswerRe: How can we access to an object of a form from another form? Pin
Luc Pattyn22-Feb-12 12:12
sitebuilderLuc Pattyn22-Feb-12 12:12 
AnswerRe: How can we access to an object of a form from another form? Pin
hellono122-Feb-12 20:50
hellono122-Feb-12 20:50 
AnswerRe: How can we access to an object of a form from another form? Pin
Quintain26-Feb-12 15:03
Quintain26-Feb-12 15:03 
QuestionRegarding AttributeUsageAttribute.AllowMultiple Pin
PIEBALDconsult22-Feb-12 8:11
mvePIEBALDconsult22-Feb-12 8:11 
QuestionHow to check that dsn which is created used for Sql Server or Access using C# Pin
Awadhendra123422-Feb-12 2:16
Awadhendra123422-Feb-12 2:16 
AnswerRe: How to check that dsn which is created used for Sql Server or Access using C# Pin
PIEBALDconsult22-Feb-12 2:56
mvePIEBALDconsult22-Feb-12 2:56 
GeneralRe: How to check that dsn which is created used for Sql Server or Access using C# Pin
Awadhendra123422-Feb-12 3:24
Awadhendra123422-Feb-12 3:24 
GeneralRe: How to check that dsn which is created used for Sql Server or Access using C# Pin
PIEBALDconsult22-Feb-12 4:00
mvePIEBALDconsult22-Feb-12 4:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.