1

特定の列に最大文字数を設定する方法を知っています..

((DataGridViewTextBoxColumn)dataGridView1.Columns[2]).MaxInputLength = 130;

しかし、その列の特定の行に最大文字数を設定する方法がわかりません..何かアイデアはありますか?

4

1 に答える 1

1

基本的に、あなたが求めているのは、最大入力長を確認し、グリッドをイベントDataGridViewCellにアタッチする必要があることを達成する方法です。EditingControlShowing

private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
   //check if currently selected cell is cell you want
   if (dataGridView1.CurrentCell == null || dataGridView1.CurrentCell.ColumnIndex != 2)
   {
       return;
   }

   if (e.Control is TextBox)
   {
       ((TextBox)e.Control).MaxLength = 130;
   }
}
于 2013-06-27T11:33:45.267 に答える