Populating DataGrid using an array

cmdolcet
cmdolcet used Ask the Experts™
on
I am having issues trying to populate a datagrid that has predefined columns. The array is 46 in length and I am trying to populate each row with the right information.

I have the code below but it only populates the first first and the first 3 cells. In the 4th cell I do have a combox, could this be what is holding it up?

  ArrayGWHIZModel = strDataCOM1.Split(New Char() {Chr(13)}, StringSplitOptions.RemoveEmptyEntries)
                    If ArrayGWHIZModel.Length = 46 Then
                        'DataGridView1.Rows.Add(ArrayGWHIZModel(0), ArrayGWHIZModel(1), True, ArrayGWHIZModel(3), True, ArrayGWHIZModel(5), ArrayGWHIZModel(6), ArrayGWHIZModel(7), ArrayGWHIZModel(8), ArrayGWHIZModel(9))
                        'DataGridView1.Rows.Add(ArrayGWHIZModel(0), ArrayGWHIZModel(1), ArrayGWHIZModel(2), ArrayGWHIZModel(3), ArrayGWHIZModel(4), ArrayGWHIZModel(5), ArrayGWHIZModel(6), ArrayGWHIZModel(7), ArrayGWHIZModel(8), ArrayGWHIZModel(9))
                        'DataGridView1.Rows.Add(ArrayGWHIZModel(0), ArrayGWHIZModel(1), ArrayGWHIZModel(2), ArrayGWHIZModel(3), ArrayGWHIZModel(4), ArrayGWHIZModel(5), ArrayGWHIZModel(6), ArrayGWHIZModel(7), ArrayGWHIZModel(8), ArrayGWHIZModel(9))
                        'DataGridView1.Rows.Add(ArrayGWHIZModel(0), ArrayGWHIZModel(1), ArrayGWHIZModel(2), ArrayGWHIZModel(3), ArrayGWHIZModel(4), ArrayGWHIZModel(5), ArrayGWHIZModel(6), ArrayGWHIZModel(7), ArrayGWHIZModel(8), ArrayGWHIZModel(9))
                        'DataGridView1.Rows.Add(ArrayGWHIZModel(0), ArrayGWHIZModel(1), ArrayGWHIZModel(2), ArrayGWHIZModel(3), ArrayGWHIZModel(4), ArrayGWHIZModel(5), ArrayGWHIZModel(6), ArrayGWHIZModel(7), ArrayGWHIZModel(8), ArrayGWHIZModel(9))
                    End If

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
John TsioumprisSoftware & Systems Engineer

Commented:
This is getting a bit more complex...
If you have a combobox on the 4th column you should change your populating strategy...
The combobox should be populated on its own.
Top Expert 2014
Commented:
The value you put in the 4th column must be one of the values you have in the DataSource of that column.

Author

Commented:
John,
How can I populate the combo box of the grid with the assigned value of the  ArrayGWHIZModel ?

louisfr,
So the  ArrayGWHIZModel value must match the string exactly that I have preloaded in the combobox?
Most Valuable Expert 2012
Top Expert 2014

Commented:
How did you populate the Combo? Did you set the DisplayMember and ValueMember? As the others have said, the value you're trying to put into that column must exactly match a value in the ValueMember of the datasource of your combo.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial