文章分類/Infragistics
如果要使用程式碼在IgbDataGrid中選擇行,請啟用行選擇功能,然後
請使用每種方法。
<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(); } ... }