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
0
1. Example
View licenseprotected override void OnDrawItem(DrawItemEventArgs e) { base.OnDrawItem (e); if (e.Index >= 0 && Items.Count > 0 && e.Index < Items.Count) { DrawItemHelperForItems(e); } }
0
2. Example
View licenseprotected override void OnDrawItem(DrawItemEventArgs e) { base.OnDrawItem(e); Invalidate(); if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { Invalidate(); } }
0
3. Example
View licenseprotected override void OnDrawItem(DrawItemEventArgs e) { base.OnDrawItem(e); Invalidate(); if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { Invalidate(); } }
0
4. Example
View licenseprotected override void OnDrawItem(DrawItemEventArgs e) { base.OnDrawItem(e); Invalidate(); if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { Invalidate(); } }
0
5. Example
View licenseprotected override void OnDrawItem(DrawItemEventArgs e) { base.OnDrawItem(e); Invalidate(); if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { Invalidate(); } }
0
6. Example
View licenseprotected 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); }
0
7. Example
View licenseprotected 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); }
0
8. Example
View licenseprotected 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); }
0
9. Example
View licenseprotected 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); } }
0
10. Example
View licenseprotected 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); }
0
11. Example
View licenseprotected override void OnDrawItem(DrawItemEventArgs e) { if (e.Index >= 0) /n ..... /n //View Source file for more details /n }
0
12. Example
View licenseprotected 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); } }
0
13. Example
View licenseprotected override void OnDrawItem(DrawItemEventArgs e) { G = e.Graphics; Rect /n ..... /n //View Source file for more details /n }
0
14. Example
View licenseprotected 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); }
0
15. Example
View licenseprotected 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); }
0
16. Example
View licenseprotected override void OnDrawItem(DrawItemEventArgs e) { base.OnDrawItem(e); TextFor/n ..... /n //View Source file for more details /n }
0
17. Example
View licenseprotected 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); } }
0
18. Example
View licenseprotected 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); }
0
19. Example
View licenseprotected 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); }
0
20. Example
View licenseprotected 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); }
0
21. Example
View licenseprotected 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); } }
0
22. Example
View licenseprotected override void OnDrawItem(DrawItemEventArgs e) { // draw background & focus rect /n ..... /n //View Source file for more details /n }
0
23. Example
View licenseprotected override void OnDrawItem(DrawItemEventArgs e) { base.OnDrawItem(e); if ((e.Index >/n ..... /n //View Source file for more details /n }
0
24. Example
View licenseprotected override void OnDrawItem(DrawItemEventArgs e) { base.OnDrawItem(e); /n ..... /n //View Source file for more details /n }