public DesinedListBox() { // スクロールバーは常に表示 ScrollAlwaysVisible = true; // デザイン調整 Font = new System.Drawing.Font("メイリオ", 8.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); ItemHeight = 18; BackColor = normalColor; // 描画は自分で行う DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; DrawItem += new System.Windows.Forms.DrawItemEventHandler(drawItem); }
public void ChangeToTreeView() { System.Windows.Forms.DrawItemEventHandler drawFunc = delegate(object sender, DrawItemEventArgs e) { ComboBox cb = (ComboBox)sender; Row row = cb.Items[e.Index] as Row; Pen pen = new Pen(Color.Gray); Brush blush = new SolidBrush(e.ForeColor); int height = e.Bounds.Bottom - e.Bounds.Top; int x = row.CaptionColumnNo * height * 3 / 2; int y = e.Bounds.Y; const int RectSize = 6; e.DrawBackground(); e.Graphics.DrawString(row.ToString(), e.Font, blush, x, y); e.Graphics.DrawRectangle(pen, new Rectangle(x - height / 2 - RectSize / 2, y + height / 2 - RectSize / 2, RectSize, RectSize)); //e.DrawFocusRectangle(); if (Convert.ToBoolean(e.State & DrawItemState.Selected)) { ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds); } }; // adjust drop down width int width = 0; int visibleColNum = 0; for (int i = 0; i < columnInfo.Count(); i++) { if (columnInfo[i].Hidden) { continue; } visibleColNum++; width = Math.Max(width, columnInfo[i].Width + visibleColNum * 12); } this.DropDownWidth = width + 32; this.DrawItem -= MyDrawItem; this.DrawItem += drawFunc; }
public CloseTabControl() { DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.Tabs_DrawItem); MouseClick += new System.Windows.Forms.MouseEventHandler(this.Tabs_MouseClick); }