文章分類/

Infragistics|Ultimate UI for WPF|IgbDataGrid – 選擇程式碼中的行。

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

infragistics log

如果要使用程式碼在IgbDataGrid中選擇行,請啟用行選擇功能,然後

  1. SelectAllRows 方法:選擇所有行。
  2. DeselectAllRows 方法:取消選取所有行。
  3. SelectedKeys的新增方法:選擇特定行。
  4. SelectedKeys的Remove方法:取消選擇特定行。

請使用每種方法。

<div style="margin: 1em">
    <IgbDataGrid Height="100%" Width="100%"
        @ref="DataGridRef"
        DataSource="People"
        SelectionMode="GridSelectionMode.MultipleRow" ...>
    </IgbDataGrid>
</div>

@code {
    ...
    private void OnSelectAllRowsClick(MouseEventArgs e)
    {
        this.DataGridRef.SelectAllRows();
    }

    private void OnSelectSomeRowsClick(MouseEventArgs e)
    {
        this.DataGridRef.SelectedKeys.Add(new IgbPrimaryKeyValue(new String[] { "ID" }, new object[] { this.People[0].ID }));
        this.DataGridRef.SelectedKeys.Add(new IgbPrimaryKeyValue(new String[] { "ID" }, new object[] { this.People[2].ID }));
    }

    private void OnDeselectSomeRowsClick(MouseEventArgs e)
    {
        foreach(IgbPrimaryKeyValue keyValue in this.DataGridRef.SelectedKeys)
        {
            if(keyValue.Key[0] == "ID" && (String)(keyValue.Value[0]) == this.People[0].ID)
            {
                this.DataGridRef.SelectedKeys.Remove(keyValue);
                break;
            }
        }
    }

    private void OnDeselectAllRowsClick(MouseEventArgs e)
    {
        this.DataGridRef.DeselectAllRows();
    }
    ...
}

快速跳轉目錄

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

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

Picture of 軟體專家
軟體專家

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

更多軟體新知

立即詢價

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

詢價資訊