作成日: 2021/02/01 最終更新日: 2021/02/01
文書種別
使用方法
詳細
列ヘッダーの水平配置を中央揃えにするには、グリッドビューとして内部的に使用されているFlexGridコントロールのOwnerDrawCellイベントにて、1行目のCellStyleのTextAlignプロパティをCenterCenterに設定するとともに、選択行の列ヘッダーのTextAlignプロパティをCenterCenterに設定します。
◎サンプルコード(VB)
◎サンプルコード(VB)
Imports C1.Win.C1FlexGrid
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
C1GanttView1.Tasks(0).Start = DateTime.Today
C1GanttView1.Tasks(0).Finish = DateTime.Today.AddDays(2)
C1GanttView1.Tasks(0).Name = "TaskA"
C1GanttView1.Tasks(0).PercentComplete = 0.5
' OwnerDrawCellイベントの追加
Dim GridView As C1FlexGrid = C1GanttView1.Controls(2)
GridView.DrawMode = DrawModeEnum.OwnerDraw
AddHandler GridView.OwnerDrawCell, AddressOf Grid_OwnerDrawCell
End Sub
Private Sub Grid_OwnerDrawCell(ByVal sender As Object, ByVal e As OwnerDrawCellEventArgs)
' 列ヘッダーを中央揃えにする
Dim GridView As C1FlexGrid = C1GanttView1.Controls(2)
GridView.Rows(0).StyleNew.TextAlign = TextAlignEnum.CenterCenter ' 非選択時
GridView.Styles.SelectedColumnHeader.TextAlign = TextAlignEnum.CenterCenter ' 選択時
End Sub
End Class
◎サンプルコード(C#)using C1.Win.C1FlexGrid;
namespace prj_C1GanttView
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
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;
// OwnerDrawCellイベントの追加
var gridView = c1GanttView1.Controls[2] as C1FlexGrid;
gridView.DrawMode = DrawModeEnum.OwnerDraw;
gridView.OwnerDrawCell += Grid_OwnerDrawCell;
}
private void Grid_OwnerDrawCell(object sender, OwnerDrawCellEventArgs e)
{
// 列ヘッダーを中央揃えにする
var gridView = c1GanttView1.Controls[2] as C1FlexGrid;
gridView.Rows[0].StyleNew.TextAlign = TextAlignEnum.CenterCenter; // 非選択時
gridView.Styles.SelectedColumnHeader.TextAlign = TextAlignEnum.CenterCenter; // 選択時
}
}
}
関連情報
旧文書番号
86374