![](/img/trans.png)
[英]how to make particular column editable for copy in datagridview of devexpress in c#?
[英]Make one cell editable in datagridview c#
我有一個datagrid視圖,其屬性為readonly = true; 但我想設置一些單元格可編輯,我嘗試用下一個代碼執行此操作:
this.dgvNoCargadas.Rows[index].Cells[columns].ReadOnly = false;
但我無法修改網格,有人有任何想法?
首先刪除dgv readonly true然后
foreach (DataGridViewRow row in DataGridView1.Rows)
{
if (condition for true)
{
row.Cells[2].ReadOnly = true;
}
else (condition for false)
{
row.Cells[2].ReadOnly = false;
}
}
嘗試:
dgvNoCargadas[columns, index].ReadOnly = false;
您可以將列中的每個單元格修改為只讀,其中單元格值不等於null或String.Empty。 這將允許用戶編輯那些空白的單元格並保護您的數據。
只需遍歷DataGridViewRow: -
Foreach(DataGridViewRow row in DataGridView1.Rows)
{
If(!row.Cells[2].Value.Equals(null) || !row.Cells[2].Value.Equals(String.Empty))
{
row.Cells[2].ReadOnly = true;
}
}
For Each row As DataGridViewRow In DataGridView1.Rows
row.Cells('Cellnumber').ReadOnly = False
Next
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.