I need to select one column and one row in a grid. I can change these selection using CTRL key with view. But how can i change both column and row selection dynamically (through code in C#)?
Hi,
Sorry, i was out of the office Friday, so i haven't had a chance to review the forums until this morning.
As for your question, i reviewed the code, and we explicitly check to see if the ctrl or shift key is down, whenever switching between different types of selection (i.e. column, cell and row). Which is why when you select a column, then a row, only the row is selected.
Unfortunately this was just a case we never considered.
However, you could just change the style of the row and column your self, when clicking an active cell and forget the row and/or column selection.
Each Column and Row has a CellStyle property, so you can use that to change the appearance, along with the ActiveCellChanging event, which gives you both the activeCell and previously activeCell, so that you can set the new one, and reset the previous one to null.
Hope this helps,
-SteveZ
Hi Stephen,
Yes it is working fine when I select CellStyle property of Row & Column in ActiveCellChanging event like here.
private void gTable_ActiveCellChanging(object sender, Infragistics.Silverlight.ActiveCellChangingEventArgs e) { if (e.PreviousActiveCell != null) { e.PreviousActiveCell.Column.CellStyle = null; ((Row)e.PreviousActiveCell.Row).CellStyle = null; } Style s = new Style(typeof(CellControl)); s.Setters.Add(new Setter(CellControl.BackgroundProperty, new SolidColorBrush(Colors.LightGray))); ((Row)e.NewActiveCell.Row).CellStyle = s; e.NewActiveCell.Column.CellStyle = s; }
Now the problem is....the default color on Selected Column/Row is different. I tried to change the default color using Expression Blend (http://help.infragistics.com/Help/NetAdvantage/Silverlight/2009.1/CLR3.5/html/SL_DesignersGuide_Editing_Style_Properties_Using_Expression_Blend.html) i.e. I select ActiveSlected item from following element tree.
But it change the color of entire Grid content. Kindly help me to synchronize the colors. Thanks