System.Windows.Forms.ComboBox.OnDrawItem(System.Windows.Forms.DrawItemEventArgs)

Here are the examples of the csharp api class System.Windows.Forms.ComboBox.OnDrawItem(System.Windows.Forms.DrawItemEventArgs) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

24 Examples 7

1. Example

Project: KeeAnywhere
Source File: ImageComboBox.cs
View license
protected override void OnDrawItem(DrawItemEventArgs e)
		{
			base.OnDrawItem (e);
			if (e.Index >= 0 && Items.Count > 0 && e.Index < Items.Count)
			{
				DrawItemHelperForItems(e);
			}
		}

2. Example

View license
protected override void OnDrawItem(DrawItemEventArgs e)
		{
			base.OnDrawItem(e);
			Invalidate();
			if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
			{
				Invalidate();
			}
		}

3. Example

View license
protected override void OnDrawItem(DrawItemEventArgs e)
		{
			base.OnDrawItem(e);
			Invalidate();
			if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
			{
				Invalidate();
			}
		}

4. Example

View license
protected override void OnDrawItem(DrawItemEventArgs e)
		{
			base.OnDrawItem(e);
			Invalidate();
			if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
			{
				Invalidate();
			}
		}

5. Example

Project: FlatUI
Source File: FlatComboBox.cs
View license
protected override void OnDrawItem(DrawItemEventArgs e)
		{
			base.OnDrawItem(e);
			Invalidate();
			if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
			{
				Invalidate();
			}
		}

6. Example

Project: NClass
Source File: ImageComboBox.cs
View license
protected override void OnDrawItem(DrawItemEventArgs e)
    {
      e.DrawBackground();
      e.DrawFocusRectangle();

      object item = e.Index >= 0 ? Items[e.Index] : null;

      ControlDrawHelper.DrawImageComboBoxItem(e.Graphics, item, ImageList, ImageSize, e.Bounds, Font, ForeColor);

      base.OnDrawItem(e);
    }

7. Example

Project: NClass
Source File: ImageComboBox.cs
View license
protected override void OnDrawItem(DrawItemEventArgs e)
    {
      e.DrawBackground();
      e.DrawFocusRectangle();

      object item = e.Index >= 0 ? Items[e.Index] : null;

      ControlDrawHelper.DrawImageComboBoxItem(e.Graphics, item, ImageList, ImageSize, e.Bounds, Font, ForeColor);

      base.OnDrawItem(e);
    }

8. Example

Project: My-FyiReporting
Source File: ColorPicker.cs
View license
protected override void OnDrawItem(DrawItemEventArgs e)
        {
            Graphics g = e.Graphics;
            Color BlockColor = Color.Empty;
            int left = RECTCOLOR_LEFT;
            if (e.State == DrawItemState.Selected || e.State == DrawItemState.None)
                e.DrawBackground();
            if (e.Index == -1)
            {
                BlockColor = SelectedIndex < 0 ? BackColor : DesignerUtility.ColorFromHtml(this.Text, Color.Empty);
            }
            else
                BlockColor = DesignerUtility.ColorFromHtml((string)this.Items[e.Index], Color.Empty);
            // Fill rectangle
            if (BlockColor.IsEmpty && this.Text.StartsWith("="))
            {
                g.DrawString("fx", this.Font, Brushes.Black, e.Bounds);
            }
            else
            {
                g.FillRectangle(new SolidBrush(BlockColor), left, e.Bounds.Top + RECTCOLOR_TOP, RECTCOLOR_WIDTH,
                    ItemHeight - 2 * RECTCOLOR_TOP);
            }
            base.OnDrawItem(e);
        }

9. Example

Project: winforms-modernui
Source File: MetroComboBox.cs
View license
protected override void OnDrawItem(DrawItemEventArgs e)
        {
            if (e.Index >= 0)
            {
                Color backColor, foreColor;

                if (e.State == (DrawItemState.NoAccelerator | DrawItemState.NoFocusRect) || e.State == DrawItemState.None)
                {
                    backColor = MetroPaint.BackColor.Form(Theme);
                    foreColor = MetroPaint.ForeColor.Link.Normal(Theme);
                }
                else
                {
                    backColor = MetroPaint.GetStyleColor(Style);
                    foreColor = MetroPaint.ForeColor.Tile.Normal(Theme);
                }

                using (SolidBrush b = new SolidBrush(backColor))
                {
                    e.Graphics.FillRectangle(b, new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height));
                }

                Rectangle textRect = new Rectangle(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height);
                TextRenderer.DrawText(e.Graphics, Items[e.Index].ToString(), MetroFonts.Link(metroLinkSize, metroLinkWeight), textRect, foreColor, backColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter);
            }
            else
            {
                base.OnDrawItem(e);
            }
        }

10. Example

Project: StackBuilder
Source File: CCtrlComboLayer.cs
View license
protected override void OnDrawItem(DrawItemEventArgs e)
        {
            e.DrawBackground();
            e.DrawFocusRectangle();
            if (!DesignMode && Items.Count > 0 && e.Index != -1)
            {
                LayerDropDownItem item = new LayerDropDownItem(
                    Items[e.Index] as ILayer2D
                    , _packable
                    , ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
                    , new Size(ItemHeight, ItemHeight)
                    , Properties.Settings.Default.LayerView3D
                    );
                e.Graphics.DrawImage(item.Image, e.Bounds.Left, e.Bounds.Top);
            }
            base.OnDrawItem(e);
        }

11. Example

Project: Mist
Source File: MetroComboBox.cs
View license
protected override void OnDrawItem(DrawItemEventArgs e)
        {
            if (e.Index >= 0)
 /n ..... /n //View Source file for more details /n }

12. Example

Project: winauth
Source File: MetroComboBox.cs
View license
protected override void OnDrawItem(DrawItemEventArgs e)
        {
            if (e.Index >= 0)
            {
                Color foreColor;

                if (e.State == (DrawItemState.NoAccelerator | DrawItemState.NoFocusRect) || e.State == DrawItemState.None)
                {
                    using (SolidBrush b = new SolidBrush(this.BackColor))
                    {
                        e.Graphics.FillRectangle(b, new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height));
                    }
									
										foreColor = MetroPaint.ForeColor.Link.Normal(Theme);
                }
                else
                {
                    using (SolidBrush b = new SolidBrush(MetroPaint.GetStyleColor(Style)))
                    {
                        e.Graphics.FillRectangle(b, new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height));
                    }

                    foreColor = MetroPaint.ForeColor.Tile.Normal(Theme);
                }

                Rectangle textRect = new Rectangle(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height);
                TextRenderer.DrawText(e.Graphics, GetItemText(Items[e.Index]), MetroFonts.ComboBox(metroComboBoxSize, metroComboBoxWeight), textRect, foreColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter);
            }
            else
            {
                base.OnDrawItem(e);
            }
        }

13. Example

Project: GoBot
Source File: DarkTheme.cs
View license
protected override void OnDrawItem(DrawItemEventArgs e)
    {
        G = e.Graphics;

        Rect /n ..... /n //View Source file for more details /n }

14. Example

View license
protected override void OnDrawItem(DrawItemEventArgs e)
        {
            e.DrawBackground();

            e.DrawFocusRectangle();

            if (e.Index >= 0 && e.Index < Items.Count)
            {
                DropDownItem item = (DropDownItem)Items[e.Index];

                if (item.Image != null)
                {
                    e.Graphics.DrawImage(item.Image, e.Bounds.Left, e.Bounds.Top);
                    e.Graphics.DrawString(item.Value, e.Font, new SolidBrush(e.ForeColor), e.Bounds.Left + item.Image.Width + 5, e.Bounds.Top + 2);
                }
                else
                    e.Graphics.DrawString(item.Value, e.Font, new SolidBrush(e.ForeColor), e.Bounds.Left, e.Bounds.Top + 2);

                
            }

            base.OnDrawItem(e);
        }

15. Example

Project: TileIconifier
Source File: SkinnableComboBox.cs
View license
protected override void OnDrawItem(DrawItemEventArgs e)
        {
            //This method is only called when items are owner drawn
            //so there is no need to check if HandleDrawing.

            e.DrawBackground();
            e.DrawFocusRectangle();

            int index = e.Index;
            if (index >= 0 && index < Items.Count)
            {
                string itemText = GetItemText(Items[index]);
                Color colTextColor = (e.State.HasFlag(DrawItemState.Selected)) ? SystemColors.HighlightText : ForeColor;                

                TextRenderer.DrawText(e.Graphics, itemText, Font, e.Bounds, colTextColor, TextFlags);
            }

            base.OnDrawItem(e);            
        }

16. Example

Project: Gorgon
Source File: ComboFonts.cs
View license
protected override void OnDrawItem(DrawItemEventArgs e)
		{
			base.OnDrawItem(e);

	        TextFor/n ..... /n //View Source file for more details /n }

17. Example

Project: DiabloInterface
Source File: FontComboBox.cs
View license
protected override void OnDrawItem(DrawItemEventArgs e)
        {
            base.OnDrawItem(e);

            // Nothing to draw.
            if (e.Index < 0 || e.Index >= Items.Count)
                return;

            e.DrawBackground();
            if ((e.State & DrawItemState.Focus) == DrawItemState.Focus)
                e.DrawFocusRectangle();

            using (var brush = new SolidBrush(e.ForeColor))
            {
                string fontFamily = Items[e.Index].ToString();

                e.Graphics.DrawString(fontFamily, GetDisplayFont(fontFamily), brush, e.Bounds, stringFormat);
            }
        }

18. Example

Project: GEDKeeper
Source File: GKComboBox.cs
View license
protected override void OnDrawItem(DrawItemEventArgs e)
        {
            e.DrawBackground();
            e.DrawFocusRectangle();

            if (e.Index < 0 || e.Index >= Items.Count) return;

            object item = Items[e.Index];
            GKComboItem ddItem = item as GKComboItem;
            if (ddItem != null) {
                int offset = e.Bounds.Left;

                if (ddItem.Image != null) {
                    e.Graphics.DrawImage(ddItem.Image, e.Bounds.Left, e.Bounds.Top);
                    offset += ddItem.Image.Width;
                }

                e.Graphics.DrawString(ddItem.Caption, e.Font, new SolidBrush(e.ForeColor),
                                      offset, e.Bounds.Top + 2);
            } else {
                e.Graphics.DrawString(item.ToString(), e.Font, new SolidBrush(e.ForeColor),
                                      e.Bounds.Left, e.Bounds.Top + 2);
            }
            base.OnDrawItem(e);
        }

19. Example

Project: GEDKeeper
Source File: GKComboBox.cs
View license
protected override void OnDrawItem(DrawItemEventArgs e)
        {
            e.DrawBackground();
            e.DrawFocusRectangle();

            if (e.Index < 0 || e.Index >= Items.Count) return;

            object item = Items[e.Index];
            GKComboItem ddItem = item as GKComboItem;
            if (ddItem != null) {
                int offset = e.Bounds.Left;

                if (ddItem.Image != null) {
                    e.Graphics.DrawImage(ddItem.Image, e.Bounds.Left, e.Bounds.Top);
                    offset += ddItem.Image.Width;
                }

                e.Graphics.DrawString(ddItem.Caption, e.Font, new SolidBrush(e.ForeColor),
                                      offset, e.Bounds.Top + 2);
            } else {
                e.Graphics.DrawString(item.ToString(), e.Font, new SolidBrush(e.ForeColor),
                                      e.Bounds.Left, e.Bounds.Top + 2);
            }
            base.OnDrawItem(e);
        }

20. Example

View license
protected override void OnDrawItem(DrawItemEventArgs e)
		{
			var itemString = e.Index >= 0 ? GetItemText(Items[e.Index]) : string.Empty;

			if ((e.State & DrawItemState.ComboBoxEdit) != DrawItemState.ComboBoxEdit)
			{
				if (e.Index >= 0)
				{
					var iEnabled = IsItemEnabled(e.Index);
					if (iEnabled)
					{
						e.DrawBackground();
						e.DrawFocusRectangle();
					}
					else
					{
						using (var bb = new SolidBrush(e.BackColor))
							e.Graphics.FillRectangle(bb, e.Bounds);
					}
					TextRenderer.DrawText(e.Graphics, itemString, e.Font, Rectangle.Inflate(e.Bounds, -2, 0), iEnabled ? e.ForeColor : SystemColors.GrayText, tff);
				}
			}
			base.OnDrawItem(e);
		}

21. Example

Project: Gorgon
Source File: ComboPatterns.cs
View license
protected override void OnDrawItem(DrawItemEventArgs e)
		{
			base.OnDrawItem(e);

			TextFormatFlags flags = TextFormatFlags.EndEllipsis | TextFormatFlags.NoPrefix | TextFormatFlags.Left | TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter;

			if ((e.Index < 0) || (e.Index >= Items.Count))
			{
				return;
			}

			if (GorgonFontEditorPlugIn.IsRightToLeft(this))
			{
				flags |= TextFormatFlags.RightToLeft;
			}

			e.DrawBackground();

			if ((e.State & DrawItemState.Focus) == DrawItemState.Focus)
			{
				e.DrawFocusRectangle();
			}

			string patternName = Items[e.Index].ToString();
		    HatchStyle style;

			if (!_patternList.TryGetValue(patternName, out style))
			{
				return;
			}

			e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
			var textBounds = new Rectangle(26 + e.Bounds.Left, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height);
			var patternBounds = new Rectangle(e.Bounds.Left + 2, e.Bounds.Top + 2, 22, e.Bounds.Height - 4);

			using (Brush brush = new HatchBrush(style, e.ForeColor, e.BackColor))
			{
				TextRenderer.DrawText(e.Graphics, patternName, Font, textBounds, e.ForeColor, e.BackColor, flags);
				e.Graphics.FillRectangle(brush, patternBounds);
				e.Graphics.DrawRectangle(Pens.Black, patternBounds);
			}
		}

22. Example

Project: AnotherSc2Hack
Source File: ImageCombobox.cs
View license
protected override void OnDrawItem(DrawItemEventArgs e)
		{
			// draw background & focus rect
     /n ..... /n //View Source file for more details /n }

23. Example

Project: SharpBoot
Source File: GroupedComboBox.cs
View license
protected override void OnDrawItem(DrawItemEventArgs e) {
		base.OnDrawItem(e);

		if ((e.Index >/n ..... /n //View Source file for more details /n }

24. Example

View license
protected override void OnDrawItem(DrawItemEventArgs e)
        {
            base.OnDrawItem(e);

 /n ..... /n //View Source file for more details /n }