Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > DataBinding to all values in column of a DataGridView
 

DataBinding to all values in column of a DataGridView

I have a datasource where a couple of the fields contain semi-colon delimited lists. When present, the lists contain values which pair with each other (one is a list of names, the other is a list of identifiers). All of the other values in my datasource contain single values and can databind to a singular control (DateTimePicker, Textbox, Checkbox, etc.). I'd like for the values in my semi-colon delimited lists to map to a datagridview where each pair of values is a new row.

For example, I'd have a data object, MyDataObject with properties .SecondaryNames = "Company 1; Company 2; Company 3" and .SecondaryIDs = "1; 15; 32" and I'd like that to be databound to a datagridview which would have two columns and three rows, {Company 1, 1}{Company 2, 15}{Company 3, 32}.

Is this at all possible using DataBinding? I'll have to write my own Parse and Format handlers but that's not a big deal, I just can't figure out how you might bind to a DataGridViewColumn. Am I just going to have to write my own Set function instead?

Thanks,
Niko
nlhoskins  Saturday, September 19, 2009 12:24 AM
I don't know of any built-in way to do this.

Normally, a column contains one field. If you need a set of data, that would be in a different table. For example, a company table wit the company Ids. Then you can use the built-int tools to bind the list to a combobox in the grid.

Hope this helps.

www.insteptech.com ; msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
DeborahK  Saturday, September 19, 2009 6:03 PM
I don't know of any built-in way to do this.

Normally, a column contains one field. If you need a set of data, that would be in a different table. For example, a company table wit the company Ids. Then you can use the built-int tools to bind the list to a combobox in the grid.

Hope this helps.

www.insteptech.com ; msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
DeborahK  Saturday, September 19, 2009 6:03 PM

You can use google to search for other answers

Custom Search

More Threads

• Better way to make a filter string
• General approach with choosing dataSource for DataGridView
• selected datarows
• TableAdapter.Insert and Identity
• Child data grid records not visible after refilling parent table
• Change timeout value for table adapter?
• modify gridview according to listbox
• DataGridViewComboBoxCell Items Collection empty
• datagridview question
• Typed DataSet connection