文章分類/Infragistics
如果要更改將 UltraGrid 的列樣式作為按鈕的單元格的顏色,
是可能的。請注意,很容易忘記設置 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"]; }
結果