MahamidShaft
New member
- Joined
- Jan 27, 2010
- Messages
- 3
- Programming Experience
- Beginner
Hello. I have one problem.
I have put DataGridView onto the form.
In design time i created 10 columns, from wich one is comboboxcolumn, so i have 9x textboxcolumns and 1x comboboxcolumn.
I also give "bound" names to every column (DataPropertyName).
"Bound" name of comboboxcolum is DataPropertyName="04_Forecast"
Then i wrote some code, where i created: mydatacolumn and mydatarow which i added to mydatatable. I created 9x myDataColumns.
myDataTable = New DataTable("Table1")
....
myDataColumn = New DataColumn
myDataColumn.DataType = System.Type.GetType("System.Single")
myDataColumn.ColumnName = "01_Name"
myDataTable.Columns.Add(myDataColumn)
....
....
I also created 10x rows for each column:
For n = 1 To 10
myDataRow = myDataTable.NewRow
myDataRow(0) = n
myDataTable.Rows.Add(myDataRow)
Next
At last i wrote:
myDataSet.Tables.Add(myDataTable)
DataGridView1.DataSource = myDataSet
DataGridView1.DataMember = "Table1"
When i run the program, i see 10 columns and 10 rows which is ok.
Now i just want to populate "comboboxcolumn" from myDataSet_1.
I already made proper DB connection, where i filled myDataSet_1 with one table "Weather" from base.
myDGVComboBoxColumn = New DataGridViewComboBoxColumn
myDGVComboBoxColumn.DataSource = myDataSet_1.Tables("Weather")
myDGVComboBoxColumn.DisplayMember = "Clouds"
myDGVComboBoxColumn.ValueMember = "Speed"
myDGVComboBoxColumn.DataPropertyName = "04_Forecast"
Now, i dont' want to add or insert new comboboxcolumn to datagridview, just want to populate existing one, which was made in design time.
If i use code like this one:
DataGridView.Columns.Add(myDGVComboBoxColumn)
, i just add new column to datagridview (11 colums in runtime), which is not good.
So the question is, how to "synchronize" datagridview with myDGVComboBoxColumn ? Is my thinking so far any good ?
Any code, examples ?
Then, if i select something in combobox item in run time, how do i access this data from valuemember ? Maybe, datagridview.rows(0).cells(2).....???
Thanks...
I have put DataGridView onto the form.
In design time i created 10 columns, from wich one is comboboxcolumn, so i have 9x textboxcolumns and 1x comboboxcolumn.
I also give "bound" names to every column (DataPropertyName).
"Bound" name of comboboxcolum is DataPropertyName="04_Forecast"
Then i wrote some code, where i created: mydatacolumn and mydatarow which i added to mydatatable. I created 9x myDataColumns.
myDataTable = New DataTable("Table1")
....
myDataColumn = New DataColumn
myDataColumn.DataType = System.Type.GetType("System.Single")
myDataColumn.ColumnName = "01_Name"
myDataTable.Columns.Add(myDataColumn)
....
....
I also created 10x rows for each column:
For n = 1 To 10
myDataRow = myDataTable.NewRow
myDataRow(0) = n
myDataTable.Rows.Add(myDataRow)
Next
At last i wrote:
myDataSet.Tables.Add(myDataTable)
DataGridView1.DataSource = myDataSet
DataGridView1.DataMember = "Table1"
When i run the program, i see 10 columns and 10 rows which is ok.
Now i just want to populate "comboboxcolumn" from myDataSet_1.
I already made proper DB connection, where i filled myDataSet_1 with one table "Weather" from base.
myDGVComboBoxColumn = New DataGridViewComboBoxColumn
myDGVComboBoxColumn.DataSource = myDataSet_1.Tables("Weather")
myDGVComboBoxColumn.DisplayMember = "Clouds"
myDGVComboBoxColumn.ValueMember = "Speed"
myDGVComboBoxColumn.DataPropertyName = "04_Forecast"
Now, i dont' want to add or insert new comboboxcolumn to datagridview, just want to populate existing one, which was made in design time.
If i use code like this one:
DataGridView.Columns.Add(myDGVComboBoxColumn)
, i just add new column to datagridview (11 colums in runtime), which is not good.
So the question is, how to "synchronize" datagridview with myDGVComboBoxColumn ? Is my thinking so far any good ?
Any code, examples ?
Then, if i select something in combobox item in run time, how do i access this data from valuemember ? Maybe, datagridview.rows(0).cells(2).....???
Thanks...