Move to Next Column DataGridView
-
Can anyone give me a code snippet for how to move to the next column of a DataGridView to insert a value. In this case, there is no DB connectivity. I am creating an application that retrieves the property names and values for a control and populates a DataGridView with these values. I can do this: foreach (PropertyInfo prop in t.GetProperties()) { dataGridView1.Rows.Add(prop.Name); dataGridView1.Rows.Add(prop.GetValue(controls[index], null)); } However, this puts the values in the same column. I have 2 columns in the gridview, and would like the output to appear similar to the properties window in VS. Any help would be greatly appreciated. Thanks!:cool:
"If you don't know where you're going, you'll probably end up somewhere else." Yogi Berra
-
Can anyone give me a code snippet for how to move to the next column of a DataGridView to insert a value. In this case, there is no DB connectivity. I am creating an application that retrieves the property names and values for a control and populates a DataGridView with these values. I can do this: foreach (PropertyInfo prop in t.GetProperties()) { dataGridView1.Rows.Add(prop.Name); dataGridView1.Rows.Add(prop.GetValue(controls[index], null)); } However, this puts the values in the same column. I have 2 columns in the gridview, and would like the output to appear similar to the properties window in VS. Any help would be greatly appreciated. Thanks!:cool:
"If you don't know where you're going, you'll probably end up somewhere else." Yogi Berra
-
Can anyone give me a code snippet for how to move to the next column of a DataGridView to insert a value. In this case, there is no DB connectivity. I am creating an application that retrieves the property names and values for a control and populates a DataGridView with these values. I can do this: foreach (PropertyInfo prop in t.GetProperties()) { dataGridView1.Rows.Add(prop.Name); dataGridView1.Rows.Add(prop.GetValue(controls[index], null)); } However, this puts the values in the same column. I have 2 columns in the gridview, and would like the output to appear similar to the properties window in VS. Any help would be greatly appreciated. Thanks!:cool:
"If you don't know where you're going, you'll probably end up somewhere else." Yogi Berra
Hi, Here is the code snippet: foreach (PropertyInfo info in t.GetProperties()) { dataGridView1.Rows.Add(); infoName = info.Name; value = info.MemberType.ToString(); } private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e) { dataGridView1.Rows[e.RowIndex].Cells[0].Value = infoName; dataGridView1.Rows[e.RowIndex].Cells[1].Value = value; } Thanks,
Gopal.S
-
Can anyone give me a code snippet for how to move to the next column of a DataGridView to insert a value. In this case, there is no DB connectivity. I am creating an application that retrieves the property names and values for a control and populates a DataGridView with these values. I can do this: foreach (PropertyInfo prop in t.GetProperties()) { dataGridView1.Rows.Add(prop.Name); dataGridView1.Rows.Add(prop.GetValue(controls[index], null)); } However, this puts the values in the same column. I have 2 columns in the gridview, and would like the output to appear similar to the properties window in VS. Any help would be greatly appreciated. Thanks!:cool:
"If you don't know where you're going, you'll probably end up somewhere else." Yogi Berra
Thank you kindly.:cool:
"If you don't know where you're going, you'll probably end up somewhere else." Yogi Berra