作成日: 2018/06/04 最終更新日: 2018/06/04
文書種別
使用方法
詳細
C1GanttViewのグリッドビューのカスタム列に、例えば「タスクモード」の「自動/手動」選択のように、コンボボックス形式のプルダウンリストを表示させるには、グリッドビューの内部コントロールであるC1FlexGridのBeforeEditイベントにて、C1GanttViewの子コントロールであるC1FlexGridを取得し、このグリッドの該当する列にComboListを設定します。
また、プルダウンリストの選択値を取得するには、C1GanttViewのAfterEditイベントで、子コントロールであるC1FlexGridの該当セルの値を参照します。
※下記サンプルでは、 設計時に、C1GanttView.Columsコレクションエディタで、 「列1」という名のカスタム列を追加してあることを前提としています。
◎サンプルコード(VB)
◎サンプルコード(C#)
また、プルダウンリストの選択値を取得するには、C1GanttViewのAfterEditイベントで、子コントロールであるC1FlexGridの該当セルの値を参照します。
※下記サンプルでは、 設計時に、C1GanttView.Columsコレクションエディタで、 「列1」という名のカスタム列を追加してあることを前提としています。
◎サンプルコード(VB)
Imports C1.Win.C1FlexGrid
Imports C1.Win.C1GanttView
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim gridView As C1FlexGrid = CType(C1GanttView1.Controls(2), C1FlexGrid)
AddHandler gridView.BeforeEdit, AddressOf gridView_BeforeEdit
AddHandler gridView.AfterEdit, AddressOf gridView_AfterEdit
End Sub
Private Sub gridView_BeforeEdit(ByVal sender As Object, ByVal e As RowColEventArgs)
Dim gridView As C1FlexGrid = CType(sender, C1FlexGrid)
gridView.BeginUpdate()
If gridView.Cols(e.Col).Name = "列1" Then
gridView.Cols(e.Col).ComboList = "A1|B1|C1|D1|E1"
End If
gridView.EndUpdate()
End Sub
Private Sub gridView_AfterEdit(ByVal sender As Object, ByVal e As RowColEventArgs)
Dim gridView As C1FlexGrid = CType(sender, C1FlexGrid)
If gridView.Cols(e.Col).Name = "列1" Then
Console.WriteLine(gridView(e.Row, e.Col).ToString())
End If
End Sub
End Class
Imports C1.Win.C1GanttView
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim gridView As C1FlexGrid = CType(C1GanttView1.Controls(2), C1FlexGrid)
AddHandler gridView.BeforeEdit, AddressOf gridView_BeforeEdit
AddHandler gridView.AfterEdit, AddressOf gridView_AfterEdit
End Sub
Private Sub gridView_BeforeEdit(ByVal sender As Object, ByVal e As RowColEventArgs)
Dim gridView As C1FlexGrid = CType(sender, C1FlexGrid)
gridView.BeginUpdate()
If gridView.Cols(e.Col).Name = "列1" Then
gridView.Cols(e.Col).ComboList = "A1|B1|C1|D1|E1"
End If
gridView.EndUpdate()
End Sub
Private Sub gridView_AfterEdit(ByVal sender As Object, ByVal e As RowColEventArgs)
Dim gridView As C1FlexGrid = CType(sender, C1FlexGrid)
If gridView.Cols(e.Col).Name = "列1" Then
Console.WriteLine(gridView(e.Row, e.Col).ToString())
End If
End Sub
End Class
◎サンプルコード(C#)
using C1.Win.C1FlexGrid;
using C1.Win.C1GanttView;
namespace Prj_DropDownInCustomField
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
C1FlexGrid gridView = ((C1FlexGrid)(c1GanttView1.Controls[2]));
gridView.BeforeEdit += gridView_BeforeEdit;
gridView.AfterEdit += gridView_AfterEdit;
}
private void gridView_BeforeEdit(object sender, RowColEventArgs e)
{
C1FlexGrid gridView = ((C1FlexGrid)(sender));
gridView.BeginUpdate();
if ((gridView.Cols[e.Col].Name == "列1"))
{
gridView.Cols[e.Col].ComboList = "A1|B1|C1|D1|E1";
}
gridView.EndUpdate();
}
private void gridView_AfterEdit(object sender, RowColEventArgs e)
{
C1FlexGrid gridView = ((C1FlexGrid)(sender));
if ((gridView.Cols[e.Col].Name == "列1"))
{
Console.WriteLine(gridView[e.Row, e.Col].ToString());
}
}
}
}
using C1.Win.C1GanttView;
namespace Prj_DropDownInCustomField
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
C1FlexGrid gridView = ((C1FlexGrid)(c1GanttView1.Controls[2]));
gridView.BeforeEdit += gridView_BeforeEdit;
gridView.AfterEdit += gridView_AfterEdit;
}
private void gridView_BeforeEdit(object sender, RowColEventArgs e)
{
C1FlexGrid gridView = ((C1FlexGrid)(sender));
gridView.BeginUpdate();
if ((gridView.Cols[e.Col].Name == "列1"))
{
gridView.Cols[e.Col].ComboList = "A1|B1|C1|D1|E1";
}
gridView.EndUpdate();
}
private void gridView_AfterEdit(object sender, RowColEventArgs e)
{
C1FlexGrid gridView = ((C1FlexGrid)(sender));
if ((gridView.Cols[e.Col].Name == "列1"))
{
Console.WriteLine(gridView[e.Row, e.Col].ToString());
}
}
}
}
旧文書番号
82818