Hi there,
Ok - So I created this simple example. I have dataGridView control which I have added some dataColums to... Check ehm out! Notice that the last on is of type boolean!
vb Code:
DataTable dt = new DataTable(); DataColumn dcId = new DataColumn(); dcId.ColumnName = "ComplexId"; dcId.DataType = System.Type.GetType("System.Int64"); dt.Columns.Add(dcId); DataColumn dcName = new DataColumn(); dcName.ColumnName = "ComplexName"; dcName.DataType = System.Type.GetType("System.String"); dt.Columns.Add(dcName); DataColumn dcTrueFalse = new DataColumn(); dcTrueFalse.ColumnName = "True/False\nLook! Two lines..."; dcTrueFalse.DataType = System.Type.GetType("System.Boolean"); dt.Columns.Add(dcTrueFalse); DataRow row = dt.NewRow(); row["ComplexId"] = 100; row["ComplexName"] = "100%"; dt.Rows.Add(row); dgSearchResults.DataSource = dt;
That's all spiffy - and just for test purposes I want to check and see what they values are when you select the row, the code is below
vb Code:
private void dgSearchResults_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { //MessageBox.Show(dgSearchResults.SelectedRows[0].Cells[0].Value.ToString()); for (int i = 0; i < dgSearchResults.SelectedRows[0].Cells.Count; i++) { MessageBox.Show(dgSearchResults.SelectedRows[0].Cells[i].Value.ToString() + "\nCurrnet index: " + dgSearchResults.SelectedRows[0].Cells[i].ToString()); } }
only problem is - how can I figure out if the last datacolumn is checked? It doesn't show anything when I run though the array of cells? Am I going abou t this in the wrong way? Is there a more efficient way to do this?
Thanks!




Reply With Quote