作成日: 2015/04/20 最終更新日: 2015/04/20
文書種別
使用方法
詳細
C1GanttViewではSortTasks(PropertyDescriptor,ListSortDirection)で単一行のソートを、SortTasks(IComparer)で複数行のソートを実装することができます。
◎サンプルコード(VB)
◎サンプルコード(C#)
◎サンプルコード(VB)
' 単一行ソート:タスク名(昇順)
Dim properties As PropertyDescriptorCollection = TypeDescriptor.GetProperties(Me.C1GanttView1.Tasks(0))
Dim myProperty As PropertyDescriptor = properties.Find("Name", False)
Me.C1GanttView1.SortTasks(myProperty, ListSortDirection.Ascending)
' 複数行ソート
Dim tc As TaskComparer = New TaskComparer
' 優先順位1:タスク名(昇順)
Dim properties1 As PropertyDescriptorCollection = TypeDescriptor.GetProperties(Me.C1GanttView1.Tasks(0))
Dim myProperty1 As PropertyDescriptor = properties1.Find("Name", False)
tc.AddPropertyComparerInfo(myProperty1, ListSortDirection.Ascending)
' 優先順位2:開始日(昇順)
Dim properties2 As PropertyDescriptorCollection = TypeDescriptor.GetProperties(Me.C1GanttView1.Tasks(0))
Dim myProperty2 As PropertyDescriptor = properties2.Find("Start", False)
tc.AddPropertyComparerInfo(myProperty2, ListSortDirection.Ascending)
' 優先順位3:終了日(降順)
Dim properties3 As PropertyDescriptorCollection = TypeDescriptor.GetProperties(Me.C1GanttView1.Tasks(0))
Dim myProperty3 As PropertyDescriptor = properties3.Find("Finish", False)
tc.AddPropertyComparerInfo(myProperty3, ListSortDirection.Descending)
Me.C1GanttView1.SortTasks(tc)
Dim properties As PropertyDescriptorCollection = TypeDescriptor.GetProperties(Me.C1GanttView1.Tasks(0))
Dim myProperty As PropertyDescriptor = properties.Find("Name", False)
Me.C1GanttView1.SortTasks(myProperty, ListSortDirection.Ascending)
' 複数行ソート
Dim tc As TaskComparer = New TaskComparer
' 優先順位1:タスク名(昇順)
Dim properties1 As PropertyDescriptorCollection = TypeDescriptor.GetProperties(Me.C1GanttView1.Tasks(0))
Dim myProperty1 As PropertyDescriptor = properties1.Find("Name", False)
tc.AddPropertyComparerInfo(myProperty1, ListSortDirection.Ascending)
' 優先順位2:開始日(昇順)
Dim properties2 As PropertyDescriptorCollection = TypeDescriptor.GetProperties(Me.C1GanttView1.Tasks(0))
Dim myProperty2 As PropertyDescriptor = properties2.Find("Start", False)
tc.AddPropertyComparerInfo(myProperty2, ListSortDirection.Ascending)
' 優先順位3:終了日(降順)
Dim properties3 As PropertyDescriptorCollection = TypeDescriptor.GetProperties(Me.C1GanttView1.Tasks(0))
Dim myProperty3 As PropertyDescriptor = properties3.Find("Finish", False)
tc.AddPropertyComparerInfo(myProperty3, ListSortDirection.Descending)
Me.C1GanttView1.SortTasks(tc)
◎サンプルコード(C#)
// 単一行ソート:タスク名(昇順)
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this.c1GanttView1.Tasks[0]);
PropertyDescriptor myProperty = properties.Find("Name", false);
this.c1GanttView1.SortTasks(myProperty, ListSortDirection.Ascending);
// 複数行ソート
TaskComparer tc = new TaskComparer();
// 優先順位1:タスク名(昇順)
PropertyDescriptorCollection properties1 = TypeDescriptor.GetProperties(this.c1GanttView1.Tasks[0]);
PropertyDescriptor myProperty1 = properties1.Find("Name", false);
tc.AddPropertyComparerInfo(myProperty1, ListSortDirection.Ascending);
// 優先順位2:開始日(昇順)
PropertyDescriptorCollection properties2 = TypeDescriptor.GetProperties(this.c1GanttView1.Tasks[0]);
PropertyDescriptor myProperty2 = properties2.Find("Start", false);
tc.AddPropertyComparerInfo(myProperty2, ListSortDirection.Ascending);
// 優先順位3:終了日(降順)
PropertyDescriptorCollection properties3 = TypeDescriptor.GetProperties(this.c1GanttView1.Tasks[0]);
PropertyDescriptor myProperty3 = properties3.Find("Finish", false);
tc.AddPropertyComparerInfo(myProperty3, ListSortDirection.Descending);
this.c1GanttView1.SortTasks(tc);
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this.c1GanttView1.Tasks[0]);
PropertyDescriptor myProperty = properties.Find("Name", false);
this.c1GanttView1.SortTasks(myProperty, ListSortDirection.Ascending);
// 複数行ソート
TaskComparer tc = new TaskComparer();
// 優先順位1:タスク名(昇順)
PropertyDescriptorCollection properties1 = TypeDescriptor.GetProperties(this.c1GanttView1.Tasks[0]);
PropertyDescriptor myProperty1 = properties1.Find("Name", false);
tc.AddPropertyComparerInfo(myProperty1, ListSortDirection.Ascending);
// 優先順位2:開始日(昇順)
PropertyDescriptorCollection properties2 = TypeDescriptor.GetProperties(this.c1GanttView1.Tasks[0]);
PropertyDescriptor myProperty2 = properties2.Find("Start", false);
tc.AddPropertyComparerInfo(myProperty2, ListSortDirection.Ascending);
// 優先順位3:終了日(降順)
PropertyDescriptorCollection properties3 = TypeDescriptor.GetProperties(this.c1GanttView1.Tasks[0]);
PropertyDescriptor myProperty3 = properties3.Find("Finish", false);
tc.AddPropertyComparerInfo(myProperty3, ListSortDirection.Descending);
this.c1GanttView1.SortTasks(tc);
旧文書番号
81257