I have created more than 5 GRID for which there are a few column that are empty/zero. These are numbered as example 1,2,3...
I have already implemented that I can select and deselect single cells for this columns.
Now my question is (and I am still very inexperienced with Infragistics)
How do I get the Name Property
of my grid just by clicking on it?
Some parameters I could read out like the cells.index or the rows.index, but I want to know for another method the exact Name Property
in which just the cell was clicked.
Via the event handler I let all my grids into the cells click method
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
}
CodePudding user response:
When the ClickCell
event occurs the first parameter of the event handler is sender and in this case it's the Infragistics.Win.UltraWinGrid.UltraGrid
source. Therefore, it is possible to get the grid name like in code below:
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}'");
}
}