We are using a RadGridView to display data in a small area, only two rows are visible at any given time with the third row partially visible. Using the RowFormatting event handler, we set the forecolor to reflect rows that contain 'inactive' or 'invalid' records based on columns in the underlying data. Generally this works fine. But when there are more than three rows in the grid and some of those rows are not visible, the forecolor change is not reliable. For example, if the first three rows are 'valid' and the fourth row is 'invalid', all appears correct when the grid is initially displayed and the user scrolls down to the fourth row. The 'invalid' row has the forecolor changed to gray. But when the fourth is selected and the user then scrolls back to the first row, the first row now shows as 'invalid' (forecolor = gray) even though the data has not changed and the other rows still display the same as before. From that point on the first row displays incorrectly until the data is refreshed. Sometimes this occurs even if the last row is not selected, just scrolling from top to bottom and back.
private void grdEFT_RowFormatting(object sender, RowFormattingEventArgs e)
{
if (e != null &&
e.RowElement.RowInfo != null &&
e.RowElement.RowInfo.DataBoundItem is DataRowView)
{
DataRow drEFT = ((DataRowView)e.RowElement.RowInfo.DataBoundItem).Row;
DataRow drAPM = drEFT.GetParentRow(this.rAutopayDS.Relations["AssociatePaymentMethodEFTPaymentMethodInfo"]);
if (drAPM != null)
{
// Show the row as inactive if it is not active.
if (!(bool)drAPM["Active"] ||
!(bool)drEFT["Valid"])
{
e.RowElement.ForeColor = System.Drawing.SystemColors.ControlDark;
}
else
{
e.RowElement.ResetValue(LightVisualElement.FontProperty, ValueResetFlags.Local);
}
}
else
{
e.RowElement.ResetValue(LightVisualElement.FontProperty, ValueResetFlags.Local);
}
}
}
Thanks,
Greg Swope
private void grdEFT_RowFormatting(object sender, RowFormattingEventArgs e)
{
if (e != null &&
e.RowElement.RowInfo != null &&
e.RowElement.RowInfo.DataBoundItem is DataRowView)
{
DataRow drEFT = ((DataRowView)e.RowElement.RowInfo.DataBoundItem).Row;
DataRow drAPM = drEFT.GetParentRow(this.rAutopayDS.Relations["AssociatePaymentMethodEFTPaymentMethodInfo"]);
if (drAPM != null)
{
// Show the row as inactive if it is not active.
if (!(bool)drAPM["Active"] ||
!(bool)drEFT["Valid"])
{
e.RowElement.ForeColor = System.Drawing.SystemColors.ControlDark;
}
else
{
e.RowElement.ResetValue(LightVisualElement.FontProperty, ValueResetFlags.Local);
}
}
else
{
e.RowElement.ResetValue(LightVisualElement.FontProperty, ValueResetFlags.Local);
}
}
}
Thanks,
Greg Swope