Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > how to set default values for data bound combobox
 

how to set default values for data bound combobox

I'm working with a vb windows forms app and using LINQ to SQL. I have a form whose values come from a SQL table. one of the items on this form is a combobox whose items come from another SQL table. My form works great when I am loading an existing record from my table and now I am trying to add the ability to create a new record with this same form. I created a new instance of the table and set my form's bindingsource's datasource to it. This all works. Now I need to set the combobox, which is data bound with its own bindingsource, to a default value. I have tried setting the combobox's .SelectedValue to the default value that I want but that doesnt work. I'm sure this is a very simple matter, so simple that the answer is hard to find, at least for me.

Thanks for any suggestions.

UPDATE:
now i noticed that i cannot update the value of a textbox (via texbox1.text="whatever") either. the answer must lie in the databinding.
  • Edited byjdroger2 Wednesday, August 26, 2009 5:00 PMnew info
  •  
jdroger2  Wednesday, August 26, 2009 3:25 AM
I've worked around the issue by setting the default values in the object before I bind it to the form.
  • Marked As Answer byjdroger2 Wednesday, August 26, 2009 6:26 PM
  •  
jdroger2  Wednesday, August 26, 2009 6:26 PM
I've worked around the issue by setting the default values in the object before I bind it to the form.
  • Marked As Answer byjdroger2 Wednesday, August 26, 2009 6:26 PM
  •  
jdroger2  Wednesday, August 26, 2009 6:26 PM

You can use google to search for other answers

Custom Search

More Threads

• Datgridview / C# problem
• datagridview checkbox column bound to bit field
• Another Serious Problem With ComboBox
• Set default sort column in datagridview
• Saving changes made to a datagridview
• How do I set a row in a GridView to edit mode?
• Hide selected cell border in DataGridView
• Changing Computer's Regional Setting Causes Lock Problems On Databound Controls
• vb.net connection string question
• DataGridView - FormatException on null in DataGridViewCheckBoxColumn