protected override void OnMeasureItem(System.Windows.Forms.MeasureItemEventArgs e) { if (_autoAdjustItemHeight) { e.ItemHeight += _separatorWidth; } base.OnMeasureItem(e); }
private void listBox1_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { Font font = ((ListBoxFontItem)listBox1.Items[e.Index]).Font; SizeF stringSize = e.Graphics.MeasureString(font.Name, font); // Set the height and width of the item e.ItemHeight = (int)stringSize.Height; e.ItemWidth = (int)stringSize.Width; }
private void ListBox1_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { if (e.Index == -1) { return; } if ((System.Convert.ToInt32(ListBox1.Items[e.Index]) % 4) == 0) { e.ItemHeight = 2; } }
private void SymbolListBox_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { switch (this.int_0) { case 0: e.ItemHeight = 40; break; case 1: e.ItemHeight = 30; break; case 2: e.ItemHeight = 50; break; default: e.ItemHeight = 40; break; } }
protected override void OnMeasureItem(System.Windows.Forms.MeasureItemEventArgs e) { if (e.Index > -1) { int w = 0; string fontstring = Items[e.Index].ToString(); Graphics g = CreateGraphics(); e.ItemHeight = (int)g.MeasureString(fontstring, new Font(fontstring, 10)).Height; w = (int)g.MeasureString(fontstring, new Font(fontstring, 10)).Width; if (both) { int h1 = (int)g.MeasureString(samplestr, new Font(fontstring, 10)).Height; int h2 = (int)g.MeasureString(Items[e.Index].ToString(), new Font("Arial", 10)).Height; int w1 = (int)g.MeasureString(samplestr, new Font(fontstring, 10)).Width; int w2 = (int)g.MeasureString(Items[e.Index].ToString(), new Font("Arial", 10)).Width; if (h1 > h2) { h2 = h1; } e.ItemHeight = h2; w = w1 + w2; } w += ttimg.Width * 2; if (w > maxwid) { maxwid = w; } if (e.ItemHeight > 20) { e.ItemHeight = 20; } } base.OnMeasureItem(e); }
private void RepresentationruleListBox_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { e.ItemHeight = 60; }
// If you set the Draw property to DrawMode.OwnerDrawVariable, // you must handle the MeasureItem event. This event handler // will set the height and width of each item before it is drawn. private void ComboBox_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { // Custom heights per item index can be done here. }
private void ColorRampComboBox_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { e.ItemHeight = 20; }
private void StyleComboBox_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { }
private void obj_MeasureItem(System.Object sender, System.Windows.Forms.MeasureItemEventArgs e) { this.OnChanged(sender); }