C# Datagrid
How to set for datagrid properties in c#.net windows application.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satish KathiPosted Nov 7, 2008, 4:05 PM
What properties you need to set?
Here is a sample code which set the readonly property of a cell to true when the value in other cell is changed
private void dgvWhere_CurrentCellChanged(object sender, EventArgs e)
{
//Enable 2 compare text box only if the operator is between
if (dgvWhere.CurrentRow.Cells["dgvcmbOperator"].Value != null && dgvWhere.CurrentRow.Cells["dgvcmbOperator"].Value.ToString().Trim() == "between")
dgvWhere.CurrentRow.Cells["dgvtxtCompare2"].ReadOnly = false;
else
{
dgvWhere.CurrentRow.Cells["dgvtxtCompare2"].Value = null;
dgvWhere.CurrentRow.Cells["dgvtxtCompare2"].ReadOnly = true;
}
DisplaySQL();
}
Hope this helps