文章分類/

Infragistics|Ultimate UI Windows Form|在 UltraGrid 未綁定列中顯示 checkbox

尚無瀏覽量
2023-02-18 更新

infragistics log


如果您想在未綁定的列中使用 checkbox,請執行以下操作:

  • 將 ColumnStyle.CheckBox 設置為列的 Style 屬性。
  • 將 bool 類型設置為列的 DataType 屬性。
  • 如果要在表頭添加複選框並實現所有選擇/清除,設置列表頭的CheckBoxVisibility。


private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{
    // unbind row 增加。
    UltraGridColumn UnboundCheckCol = e.Layout.Bands[0].Columns.Add("UnboundCheck", "Unbound Check");

    // row 的 Style property 的 ColumnStyle.CheckBox 設定。
    UnboundCheckCol.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox;

    // row 的 DataType property 的 bool 型別設定。
    UnboundCheckCol.DataType = typeof(bool);

    // header 也要加上 checkbox 的全選/全取消的功能的話,設定 row 表頭的 CheckBoxVisibility
    UnboundCheckCol.Header.CheckBoxVisibility = HeaderCheckBoxVisibility.Always;
}


如果要檢索按鈕單擊等事件選中的行,則可以檢查復選框列 Value 是 true 還是 false


private void button1_Click(object sender, EventArgs e)
{
    UltraGrid grid = ultraGrid1;

    System.Diagnostics.Debug.WriteLine("");
    foreach (var row in grid.Rows)
    {
        System.Diagnostics.Debug.WriteLine("(Row {0}) 被選取?: {1}", row.Index, row.Cells["UnboundCheck"].Value);
    }
}

參考文件:

將未綁定的列添加到 WinGrid https://jp.infragistics.com/help/winforms/wingrid-adding-unbound-columns-to-wingrid

使用 ColumnStyle 分配編輯器 https://jp.infragistics.com/help/winforms/wingrid-assigning-an-editor-using-columnstyle

在列標題中顯示複選框 https://jp.infragistics.com/help/winforms/wingrid-displaying-checkbox-in-column-header

快速跳轉目錄

✦ 群昱 AccessSoft 你的全面軟體解決方案 ✦

身為全球眾多知名軟體在台灣合作夥伴,歡迎諮詢你需要的軟體服務!

Picture of 軟體專家
軟體專家

群昱作為全球知名軟體推薦合作夥伴,致力於提供更多軟體解決方案給你!

更多軟體新知

立即詢價

請留下完整資訊,以便我們提供精確的服務內容給你。

詢價資訊