Version 9.2 - UltraOptionSet with two options: "Buy" and "Sell". When "Buy" is checked, any selected rows need to be Color.Lime, Color.Pink for "sell". I don't pick the colors :)
The grid's selection strategy is overridden based on another forum post so that we only allow certain bands to be selected based on other control options. Then use the mouseup event to see if a row selector element was clicked and toggle the selection of the row:
private void gridBuySell_MouseUp(object sender, MouseEventArgs e){ UltraGrid grid = sender as UltraGrid;
// Get the row that was clicked on, if any. UltraGridRow row = this.GetRowFromPoint(grid, new Point(e.X, e.Y));
if (row != null) { if (row.Band.Index == _LevelOfDimension) { // Clear any cell or column selection. grid.Selected.Cells.Clear(); grid.Selected.Columns.Clear();
// Toggle the selection of the row. row.Selected = !row.Selected; } }}
So, I need to probably try something here in this event(?), which I have:
if (row.Selected){ switch (_BuySellInd) { case "Buy": row.Appearance.BackColor = Color.Lime; break; case "Sell": row.Appearance.BackColor = Color.Pink; break; default: row.Appearance.BackColor = Color.White; break; }}else{ row.Appearance.BackColor = Color.White;}
I found other posts on the web where the solution was to use the "RowSelectionChange" event, but this event is not in version 9.2. I did try the same code above in the grid_BeforeSelectChange with no luck, mainly because you don't know if the row was selected or de-selected. Thanks!!!
Sorry to waste anyone's time. I figured-out how to do this and I am embarassed to have created this post. It was simple, I change the row color property of the grid in the ValueChanged event of the UltraOptionSet:
private void optAction_ValueChanged(object sender, EventArgs e){ switch (this.optAction.CheckedItem.DisplayText) { case "Buy": this.ucPanel1.gridBuySell.DisplayLayout.Override.SelectedRowAppearance.BackColor = Color.Lime; break; case "Sell": this.ucPanel1.gridBuySell.DisplayLayout.Override.SelectedRowAppearance.BackColor = Color.Pink; break; default: this.ucPanel1.gridBuySell.DisplayLayout.Override.SelectedRowAppearance.BackColor = Color.White; break; }
}
My problem was trying to change the row color within the grid's mouseup event where I am allowing multiple row selections without the need to hold the Ctrl key.
Hi Mike, Yes I have a problem accomplishing what the client wants. The code I posted was to show two things: 1.) That I had overridden the selection strategy for the grid so mulitple rows can be selected without having to hold the Ctrl key. 2.) That attempts had been made to accomplish the following, which I opened with in the post:
Version 9.2 - UltraOptionSet with two options: "Buy" and "Sell". When "Buy" is checked, any selected rows need to be Color.Lime, Color.Pink for "sell".
So this is the goal. If the user selects Buy, any selected rows in the grid should be colored green. If they select Sell, any selected rows should be colored pink. It is fine if the toggle between Buy and Sell clears the selected rows if they change their mind after making the initial selection, whereby they need to reselect the rows which will now be colored appropriately.
Thanks!!!
Hi,
I assume since you posted this here on the forums that you are having a problem with this code, but there is nothing in your post that indicates what the problem is or what your question is.What is the behavior you are getting?
At a wild guess, I assume that this code does nothing, because the selected appearance of the row is overriding the row.Appearance.
If that is the case, then you probably need to loop through every cell in the row and set the cell.SelectedAppearance.BackColor.
If that's not the problem, then please let me know what your question is so I can try to help. :)