HomeActive Query BuilderSet a border, or backColor of a DataSourceControl

Set a border, or backColor of a DataSourceControl


Hi

I want to set a table as Main Table in my Query and I want the user to set it my right clicking on the DataSource Control and select menuItem. I have added a Custom MenuItem to the contrext menu as mentioned in the knowledge base. But I want to set an indication on the DataSourceControl, like the backColor or Border to 'Red'

Can you tell me if this is possible and if so how I Can come around to do it

Many thanks
- Harindya
Harindya | email
May 30 2012, 10:33 AM
Dear Harindya,

The only way to customize the field list background is to draw whole control content manually using FieldListDrawItem event.
Example:

void queryBuilder1_FieldListDrawItem(Graphics g, Rectangle rect, DrawItemState state, MetadataField field, ref bool handled)
{
Brush bgBrush;
Color textColor;
String s = String.Empty;

if ((state & DrawItemState.Selected) == DrawItemState.Selected)
{
bgBrush = SystemBrushes.Highlight;
textColor = SystemColors.HighlightText;
}
else
{
bgBrush = new SolidBrush(Color.LightYellow);
textColor = Color.MediumSeaGreen;
}

rect.X -= rect.Height;
rect.Width += rect.Height;

g.FillRectangle(bgBrush, rect);

if (field != null)
{
if (!String.IsNullOrEmpty(field.AltName) && queryBuilder1.UseAltNames)
{
s = field.AltName;
}
else
{
s = field.Name.QualifiedNameWithoutQuotes;
}
}
else
{
s = "*";
}

TextRenderer.DrawText(g, s, new Font("Arial", 8, FontStyle.Bold), rect.Location, textColor);

if ((state & DrawItemState.Focus) == DrawItemState.Focus)
{
ControlPaint.DrawFocusRectangle(g, rect);
}

handled = true;
}
Eugene Starkov | email
1 day, 18 hours since original post
This topic is closed