How to populate textbox with data , using selected combobox items


private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { combobox.items.add=("peter magdy"); if (combobox.selecteditems=("peter magdy") textbox.text==("age 23, male, etc"); }

this code helps you to populate textbox with value from combobox


Consider this

// your person model where you hold person info public class Person { public int Id {get; set;} public string Name {get; set;} public int Age {get; set;} public string Sex {get; set;} } // You will hold not strings but real objects in combo private void LoadCombo() { var john = new Pesron(){Id = 0, Name = "John", Age = 20, sex = "Male"}; var maria = new Pesron(){Id = 1, Name = "Maria", Age = 19, sex = "Female"}; var couple = new []{john, maria}; combobox.DataSourse = couple; combobox.DisplayMember = "Name"; combobox.ValueMember = "Id"; } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { // Then you can have entire person information at your disposal var p = (Person)combobox.SelectedItem; textbox.text = string.Format("Name {0}, Age {1}", p.Name, p.Age); }


Try this.

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { comboBox1.Items.Add("peter magdy"); if (comboBox1.SelectedItem == "peter magdy") textBox.Text = "age 23, male, etc"; }

Maybe you will have to change names of components (in code or in the winform designer), though.


Textbox have Text property which can set/get text.

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { combobox.items.add=("peter magdy"); if (combobox.selecteditems=("peter magdy") textbox.Text ="age 23, male, etc"; }


Try also seeing for SelectionChangeComitted event in place of selectionIndexChange.

SelectionChangeComitted is a last event of the selection which should be the place just before the value is set to comboBox.

SelectedIndex change may not come when when you use up and down arrows in comboBox but the text of comboBox still changes.


  • ASIO chat session class throws exception on destruction: C++ ASIO
  • How to get boolean property with expression language?
  • Purescript types for buildQueryString function
  • Alfresco - Get username in workflow
  • How to do JOIN ON query using Criteria API
  • Mockery and Laravel constructor injection
  • How to access recipient on sent messages page with mailboxer
  • F#: In which memory area is the continuation stored: stack or heap?
  • Double dispatch in Java example
  • conditions for accessors in Coldfusion ORM
  • Django return user model id with L
  • In Java, how can I construct a File from a resource?
  • Most efficient way to move table rows from one table to another
  • Do query loads all the data in memory
  • Looking for good analogy/examples for monitor verses semaphore
  • Date Conversion from yyyy-mm-dd to dd-mm-yyyy
  • Debug.DrawLine not showing in the GameView
  • CSS Linear-gradient formatting issue accross different browsers
  • Weird JavaScript statement, what does it mean?
  • Cannot Parse HTML Data Using Android / JSOUP
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • JTable with a ScrollPane misbehaving
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Java static initializers and reflection
  • How to stop GridView from loading again when I press back button?
  • unknown Exception android
  • MATLAB: Piecewise function in curve fitting toolbox using fittype
  • Sorting a 2D array using the second column C++
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Binding checkboxes to object values in AngularJs
  • Observable and ngFor in Angular 2
  • How can I use `wmic` in a Windows PE script?
  • failed to connect to specific WiFi in android programmatically
  • Unable to use reactive element in my shiny app
  • Python/Django TangoWithDjango Models and Databases
  • java string with new operator and a literal
  • How can I use threading to 'tick' a timer to be accessed by other threads?