我創建了 5 個以上的 GRID,其中有幾列為空/零。這些被編號為示例 1,2,3...
我已經實作了可以為此列選擇和取消選擇單個單元格。
現在我的問題是(我對 Infragistics 仍然很缺乏經驗)
我如何Name Property通過點擊它來獲得我的網格?
我可以讀出一些引數,例如 cells.index 或 rows.index,但我想通過另一種方法了解Name Property僅在其中單擊了單元格的確切資訊。
通過事件處理程式,我讓所有網格進入單元格單擊方法
private void GRD_LIST_Grid_ClickCell(object sender, Infragistics.Win.UltraWinGrid.ClickCellEventArgs e)
{
if (e.Cell.Column.ToString().Contains("BAHN") && e.Cell.Tag == "1") //1-5 Column have the name "BAHN", the Tag is for an flag if the cell is clicked before
{
e.Cell.Selected = false;
e.Cell.Tag = null;
SetPrio(e.Cell.Row.Index, e.Cell.Column.Index);
}
else if (e.Cell.Column.ToString().Contains("BAHN") && e.Cell.Tag == null)
{
SetPrio(e.Cell.Row.Index, e.Cell.Column.Index);
e.Cell.Tag = "1";
}
//when the cell is click show the cell in green
if (e.Cell.Tag == "1")
{
e.Cell.Row.Cells[e.Cell.Column.ToString()].Appearance.BackColor = System.Drawing.Color.Green;
}
else if (e.Cell.Tag == null)
{
e.Cell.Row.Cells[e.Cell.Column.ToString()].Appearance.BackColor = System.Drawing.Color.FromArgb(234,244,243);
}
ClearSelectedRow(); //a Method where i set all grids in an array and clear all rows because i dont know which grid i am
}
uj5u.com熱心網友回復:
當ClickCell事件發生時,事件處理程式的第一個引數是發送者,在本例中它是Infragistics.Win.UltraWinGrid.UltraGrid源。因此,可以像下面的代碼一樣獲取網格名稱:
private void GRD_LIST_Grid_ClickCell(object sender, Infragistics.Win.UltraWinGrid.ClickCellEventArgs e)
{
if (sender is Infragistics.Win.UltraWinGrid.UltraGrid ugrid)
{
System.Diagnostics.Debug.WriteLine($"The ClickCell event is raised by '{ugrid.Name}'");
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/537450.html
標籤:C#窗体网格基础设施
上一篇:如何防止int型別的文本框為空值
