作成日: 2019/10/24 最終更新日: 2019/10/24
文書種別
使用方法
詳細
コンボボックスで選択された項目のインデックスは、ComboBoxEditorクラスのSelectedIndexプロパティで、テキストはSelectedItemプロパティで取得できます。これらは、現在アクティブなComboBoxエディタがある場合にのみ使用可能なため、C1FlexGridのComboCloseUpイベントなどで有効になります。
なおこの選択値は、ドロップダウンが閉じられた後にセルの値として割り当てられるため、ComboCloseUpイベントでGetDataメソッドを実行してセルの値を取得すると、前回の選択値が返されます。この場合、AfterEditイベント等を使用してください。
◎サンプルコード(VB)
◎サンプルコード(C#)
なおこの選択値は、ドロップダウンが閉じられた後にセルの値として割り当てられるため、ComboCloseUpイベントでGetDataメソッドを実行してセルの値を取得すると、前回の選択値が返されます。この場合、AfterEditイベント等を使用してください。
◎サンプルコード(VB)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
C1FlexGrid1.Cols(1).ComboList = "#0:仙台|#1:東京|#2:京都|#3:大阪"
End Sub
Private Sub C1FlexGrid1_ComboCloseUp(sender As Object, e As C1.Win.C1FlexGrid.RowColEventArgs) Handles C1FlexGrid1.ComboCloseUp
Label1.Text = C1FlexGrid1.ComboBoxEditor.SelectedIndex.ToString()
Label2.Text = C1FlexGrid1.ComboBoxEditor.SelectedItem
Label3.Text = C1FlexGrid1.GetData(e.Row, e.Col) '前回選択された値を返す
End Sub
Private Sub C1FlexGrid1_AfterEdit(sender As Object, e As C1.Win.C1FlexGrid.RowColEventArgs) Handles C1FlexGrid1.AfterEdit
Label4.Text = C1FlexGrid1.ComboBoxEditor.SelectedIndex.ToString() 'アクティブでないため使用不可
Label5.Text = C1FlexGrid1.ComboBoxEditor.SelectedIndex.ToString() 'アクティブでないため使用不可
Label6.Text = C1FlexGrid1.GetData(e.Row, e.Col)
End Sub
C1FlexGrid1.Cols(1).ComboList = "#0:仙台|#1:東京|#2:京都|#3:大阪"
End Sub
Private Sub C1FlexGrid1_ComboCloseUp(sender As Object, e As C1.Win.C1FlexGrid.RowColEventArgs) Handles C1FlexGrid1.ComboCloseUp
Label1.Text = C1FlexGrid1.ComboBoxEditor.SelectedIndex.ToString()
Label2.Text = C1FlexGrid1.ComboBoxEditor.SelectedItem
Label3.Text = C1FlexGrid1.GetData(e.Row, e.Col) '前回選択された値を返す
End Sub
Private Sub C1FlexGrid1_AfterEdit(sender As Object, e As C1.Win.C1FlexGrid.RowColEventArgs) Handles C1FlexGrid1.AfterEdit
Label4.Text = C1FlexGrid1.ComboBoxEditor.SelectedIndex.ToString() 'アクティブでないため使用不可
Label5.Text = C1FlexGrid1.ComboBoxEditor.SelectedIndex.ToString() 'アクティブでないため使用不可
Label6.Text = C1FlexGrid1.GetData(e.Row, e.Col)
End Sub
◎サンプルコード(C#)
private void Form1_Load(object sender, EventArgs e)
{
c1FlexGrid1.Cols[1].ComboList = "#0:仙台|#1:東京|#2:京都|#3:大阪";
}
private void c1FlexGrid1_ComboCloseUp(object sender, C1.Win.C1FlexGrid.RowColEventArgs e)
{
Label1.Text = c1FlexGrid1.ComboBoxEditor.SelectedIndex.ToString();
Label2.Text = c1FlexGrid1.ComboBoxEditor.SelectedItem.ToString();
if (c1FlexGrid1.GetData(e.Row, e.Col) != null)
{
Label3.Text = c1FlexGrid1.GetData(e.Row, e.Col).ToString(); // 前回選択された値を返す
}
}
private void c1FlexGrid1_AfterEdit(object sender, C1.Win.C1FlexGrid.RowColEventArgs e)
{
Label4.Text = c1FlexGrid1.ComboBoxEditor.SelectedIndex.ToString(); // アクティブでないため使用不可
if (c1FlexGrid1.ComboBoxEditor.SelectedItem != null)
{
Label5.Text = c1FlexGrid1.ComboBoxEditor.SelectedItem.ToString(); // アクティブでないため使用不可
}
Label6.Text = c1FlexGrid1.GetData(e.Row, e.Col).ToString();
}
{
c1FlexGrid1.Cols[1].ComboList = "#0:仙台|#1:東京|#2:京都|#3:大阪";
}
private void c1FlexGrid1_ComboCloseUp(object sender, C1.Win.C1FlexGrid.RowColEventArgs e)
{
Label1.Text = c1FlexGrid1.ComboBoxEditor.SelectedIndex.ToString();
Label2.Text = c1FlexGrid1.ComboBoxEditor.SelectedItem.ToString();
if (c1FlexGrid1.GetData(e.Row, e.Col) != null)
{
Label3.Text = c1FlexGrid1.GetData(e.Row, e.Col).ToString(); // 前回選択された値を返す
}
}
private void c1FlexGrid1_AfterEdit(object sender, C1.Win.C1FlexGrid.RowColEventArgs e)
{
Label4.Text = c1FlexGrid1.ComboBoxEditor.SelectedIndex.ToString(); // アクティブでないため使用不可
if (c1FlexGrid1.ComboBoxEditor.SelectedItem != null)
{
Label5.Text = c1FlexGrid1.ComboBoxEditor.SelectedItem.ToString(); // アクティブでないため使用不可
}
Label6.Text = c1FlexGrid1.GetData(e.Row, e.Col).ToString();
}
旧文書番号
84581