作成日: 2020/11/17 最終更新日: 2020/11/17
文書種別
使用方法
詳細
DataTypeをBooleanに設定したCustomFieldをC1GanttViewに追加し、チェックボックスのON/OFFを切り替えても、内部的にタスクの編集完了と見なさないため、AfterEditTaskイベントが発生しません。
代替方法として、C1GanttViewのグリッド部で内部使用されているC1FlexGridのMouseDownイベントでHitTestメソッドを使用し、チェックボックス上のクリックなら、AfterEditTaskイベントで呼び出されるC1GanttView_AfterEditTask()関数を強制的に実行するという手法が考えられます。
◎サンプルコード(VB)
代替方法として、C1GanttViewのグリッド部で内部使用されているC1FlexGridのMouseDownイベントでHitTestメソッドを使用し、チェックボックス上のクリックなら、AfterEditTaskイベントで呼び出されるC1GanttView_AfterEditTask()関数を強制的に実行するという手法が考えられます。
◎サンプルコード(VB)
Imports C1.Win.C1GanttView
Imports C1.Win.C1FlexGrid
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' カスタムフィールドの追加
Dim customCol As CustomFieldColumn = New CustomFieldColumn()
customCol.Caption = "customField"
customCol.Name = "customField"
customCol.DataType = GetType(Boolean)
customCol.Visible = True
C1GanttView1.Columns.Add(customCol)
' タスクの設定
C1GanttView1.Tasks(0).Start = DateTime.Today
C1GanttView1.Tasks(0).Finish = DateTime.Today.AddDays(3)
C1GanttView1.Tasks(0).Name = "TaskAAA"
C1GanttView1.Tasks(0).PercentComplete = 0.5
C1GanttView1.Tasks(0).SetFieldValue("customField", True)
' グリッド内部のC1FlexGridのMouseDownイベント追加
Dim c1FlexGrid1 As C1FlexGrid = C1GanttView1.Controls(2)
AddHandler c1FlexGrid1.MouseDown, AddressOf C1FlexGrid1_MouseDown
End Sub
Private Sub C1FlexGrid1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim grid As C1FlexGrid = TryCast(C1GanttView1.Controls(2), C1FlexGrid)
Dim ht As HitTestInfo = grid.HitTest(e.X, e.Y)
If ht.Type = HitTestTypeEnum.Checkbox Then
Dim ee As CancelTaskArgs = New CancelTaskArgs(C1GanttView1.Tasks(ht.Row - 1))
C1GanttView1_AfterEditTask(C1GanttView1, ee)
End If
End Sub
Private Sub C1GanttView1_AfterEditTask(sender As Object, e As C1.Win.C1GanttView.CancelTaskArgs) Handles C1GanttView1.AfterEditTask
MessageBox.Show("C1GanttView1_AfterEditTask イベント")
End Sub
End Class
◎サンプルコード(C#)using C1.Win.C1GanttView;
using C1.Win.C1FlexGrid;
namespace prj_C1GanttView
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// カスタムフィールドの追加
CustomFieldColumn customCol = new CustomFieldColumn();
customCol.Caption = "customField";
customCol.Name = "customField";
customCol.DataType = typeof(Boolean);
customCol.Visible = true;
c1GanttView1.Columns.Add(customCol);
// タスクの設定
c1GanttView1.Tasks[0].Start = DateTime.Today;
c1GanttView1.Tasks[0].Finish = DateTime.Today.AddDays(3);
c1GanttView1.Tasks[0].Name = "TaskAAA";
c1GanttView1.Tasks[0].PercentComplete = 0.5;
c1GanttView1.Tasks[0].SetFieldValue("customField", true);
// グリッド内部のC1FlexGridのMouseDownイベント追加
C1FlexGrid c1FlexGrid1 = (C1FlexGrid)c1GanttView1.Controls[2];
c1FlexGrid1.MouseDown += c1FlexGrid1_MouseDown;
}
private void c1FlexGrid1_MouseDown(object sender, MouseEventArgs e)
{
C1FlexGrid grid = c1GanttView1.Controls[2] as C1FlexGrid;
HitTestInfo ht = grid.HitTest(e.X, e.Y);
if (ht.Type == HitTestTypeEnum.Checkbox)
{
CancelTaskArgs ee = new CancelTaskArgs(c1GanttView1.Tasks[ht.Row - 1]);
c1GanttView1_AfterEditTask(c1GanttView1, ee);
}
}
private void c1GanttView1_AfterEditTask(object sender, CancelTaskArgs e)
{
MessageBox.Show("c1GanttView1_AfterEditTaskイベント");
}
}
}
旧文書番号
86191