私のwinformsアプリケーションでは、DataGridView
1つの行がDataGridViewComboBoxColumnコントロールを使用して、この列のコンボボックスが含まれる場所があります。
その列のコンボボックスの一部をプログラムで別のものに置き換えることは可能ですか?(たとえば、「n / a」というラベル)。特定の行にのみコンボボックスが必要です。
私のwinformsアプリケーションでは、DataGridView
1つの行がDataGridViewComboBoxColumnコントロールを使用して、この列のコンボボックスが含まれる場所があります。
その列のコンボボックスの一部をプログラムで別のものに置き換えることは可能ですか?(たとえば、「n / a」というラベル)。特定の行にのみコンボボックスが必要です。
DataGridViewComboBoxCell
プロパティの代わりにプロパティを使用する必要がありDataGridViewComboBoxColumn
ます。以下のようなもの:
for(int intCount=0;intCount<dgv.Rows.Count;intCount++)
{
if(intCount % 2 == 0) //Your own condition here
{
DataGridViewComboBoxCell cmb = new DataGridViewComboBoxCell();
//cmb.Value // assign values in the combobox
dgv[0,intCount] = cmb;
}
else
{
DataGridViewTextBoxCell txt = new DataGridViewTextBoxCell();
txt.Value = "n/a";
dgv[0,intCount] = txt;
}
}
上記の例では、最初の列に個別のセルのプロパティを割り当てています。