C# Datagrid
How to set for datagrid properties in c#.net windows application.
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satish KathiRank #8,369 · 223 reputationPosted Nov 7, 2008, 11:05 AM EST
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