Infragistics|Ultimate UI for Windows Forms|我想更改 UltraGrid 按鈕樣式單元格的顏色

infragistics log


如果要更改將 UltraGrid 的列樣式作為按鈕的單元格的顏色,

  1. 將 UseOsThemes 設置為 False。
  2. 在 ButtonAppearance 中指定顏色。

是可能的。請注意,很容易忘記設置 UseOsThemes。

private void Form1_Load(object sender, EventArgs e)
{
    ultraGrid1.UseOsThemes = Infragistics.Win.DefaultableBoolean.False;
}

private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{
    UltraGridColumn buttonColumn = e.Layout.Bands[0].Columns.Add("ButtonColumn", "Button Column");
    buttonColumn.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Button;
    buttonColumn.ButtonDisplayStyle = ButtonDisplayStyle.Always;

    
    if (false == e.Layout.Appearances.Exists("Yellow"))
    {
        Infragistics.Win.Appearance yellowAppearance = e.Layout.Appearances.Add("Yellow");
        yellowAppearance.ThemedElementAlpha = Infragistics.Win.Alpha.Transparent;
        yellowAppearance.BackColor = Color.Yellow;
        yellowAppearance.ForeColor = Color.Black;
    }
}

private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
{
    e.Row.Cells["ButtonColumn"].Value = "Click Here";

    e.Row.Cells["ButtonColumn"].ButtonAppearance = e.Row.Band.Layout.Appearances["Yellow"];
}


結果



延伸閱讀
aa71435723的大頭照
Winston

Eggplant DAI 自動化測試專家。

留言