static int SelectColumnIndex = 0;
PerformAction_Click(object sender, System.EventArgs e)
{
string data = string.Empty;
foreach(DataGridViewRow row in MyDataGridView.Rows)
{
if(row.Cells[SelectColumnIndex].Value!=null &&
Convert.ToBoolean(row.Cells[SelectColumnIndex].Value) == true)
{
foreach(DataGridViewCell cell in row.Cells)
{
if(cell.OwningColumn.Index!= SelectColumnIndex)
{
data+= (cell.Value + " ") ; // do some thing
}
}
data+="\n";
}
}
MessageBox.Show(data, "Data");
}
And if we want to get the value of a particular column, use the code below :
static int SelectColumnIndex = 0;
PerformAction_Click(object sender, System.EventArgs e)
{
string data = string.Empty;
foreach(DataGridViewRow row in MyDataGridView.Rows)
{
if(row.Cells[SelectColumnIndex].Value!=null &&
Convert.ToBoolean(row.Cells[SelectColumnIndex].Value) == true)
{
foreach(DataGridViewCell cell in row.Cells)
{
if(cell.OwningColumn.Index!= SelectColumnIndex)
{
data+= (row.Cells[1].Value + " ") ; // do some thing
}
}
data+="\n";
}
}
MessageBox.Show(data, "Data");
}
Hoping to get success Row.Dock Style property by the help of the article.Its also useful in data grid.
ReplyDeletehttp://www.dapfor.com/en/net-suite/net-grid/features/headers-and-columns