Dear all,
I have below code but don't know why the background color seems not matching with the logic. Is it because of inserting sequence??
private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
{
try
decimal newQty = Convert.ToDecimal(e.Row.Cells["itemNewQtyCol"].Value);
decimal cancelQty = Convert.ToDecimal(e.Row.Cells["itemCancelQtyCol"].Value);
if (newQty > 0 || cancelQty > 0)
e.Row.Appearance.BackColor = COLOR_NEW;
}
else
e.Row.Appearance.BackColor = COLOR_NOT_DONE;
catch (Exception ex)
{ }
To enabled the selection overlay, you just have to set the color.
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; layout.SelectionOverlayColor = SystemColors.Highlight; }
You can also set the SelectionOverlayBorderColor and SelectionOverlayBorderThickness if you like.
You don't have to worry about the original color of the row, because it never changes - the overlay simply draw on top of it. So yes, when the row is unselected it will return to it's original color.
I think Selection Overlay may work. But could you give me some sample code??
Moreover, if selected row become unselected, would it become the original background color??
What behavior do you want when a row is selected?
One thing you could do is use the SelectionOverlay properties so that selected rows appear with a semi-transparent overlay and or a border, so you can still see the cell color under the overlay.
Another option would be to set the selected appearance on the cell or row.
I find one reason for this may be there exists one logic in the ultragrid. It is for selection color in the ultragrid. If there exists one blue selected row color, how to handle three colors state??
Hello rchiu5hk,
Thanks for provided code, but I think that everything works properly according the logic in the method. Could you please explain more deeply what is wrong. Please take a look at the attached screenshot with results from my test and let me know if you think that I misunderstand your issue. Feel free to ask me if you have any questions.
decimal newQty = Convert.ToDecimal(e.Row.Cells["A"].Value);
decimal cancelQty = Convert.ToDecimal(e.Row.Cells["B"].Value);
if (newQty > 0 || cancelQty > 0)e.Row.Appearance.BackColor =Color.Yellow;
else e.Row.Appearance.BackColor =Color.Red;
MessageBox.Show(ex.ToString());