HomeActive Query BuilderSet the backColor of a single cell in the CriteriaList

Set the backColor of a single cell in the CriteriaList


Hi,

Can you tell me if its possible to set the backColor of a single Cell (Eg: Alias cell) in the CriteriaList.

Many thanks
- Harindya
Harindya | email
June 7 2012, 10:54 AM
The following example makes Alias cells red if no alias specified:

private void queryBuilder1_ControlCreated(ControlOwner owner, Control control)
{
if (control is CriteriaListControl)
{
((CriteriaListControl) control).CellPainting += Form1_CellPainting;
}
}

private void queryBuilder1_ControlDestroying(ControlOwner owner, Control control)
{
if (control is CriteriaListControl)
{
((CriteriaListControl) control).CellPainting -= Form1_CellPainting;
}
}

void Form1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
CriteriaListControl criteriaListControl = (CriteriaListControl) sender;

if (e.ColumnIndex == 3 && e.RowIndex >= 0 && e.RowIndex < criteriaListControl.CriteriaList.Count)
{
CriteriaItem criteriaItem = criteriaListControl.CriteriaList[e.RowIndex];

if (criteriaItem.Select && String.IsNullOrEmpty(criteriaItem.AliasString))
{
e.CellStyle.BackColor = Color.Pink;
}
}
}
Eugene Starkov | email
17 hours, 26 mins since original post
Dear Eugene,

Thanks, This worked perfectly

- Harindya
Harindya | email
21 hours, 8 mins since original post
This topic is closed