public override Size GetPreferredSize(Size proposedSize) { Size preferredSize = base.GetPreferredSize(proposedSize); int num = 0; if (base.Items.Count == 0) { num = 80; } else { using (Graphics graphics = Graphics.FromHwndInternal(base.Handle)) { for (int i = 0; i < base.Items.Count; i++) { if (this.DrawMode == System.Windows.Forms.DrawMode.Normal) { Size size2 = TextRenderer.MeasureText(graphics, base.GetItemText(base.Items[i]), this.Font); num = Math.Max(num, size2.Width); } else { MeasureItemEventArgs e = new MeasureItemEventArgs(graphics, i); this.OnMeasureItem(e); num = Math.Max(num, e.ItemWidth); } } } } preferredSize.Width = Math.Max(this.MinimumSize.Width, (num + (SystemInformation.Border3DSize.Width * 2)) + SystemInformation.VerticalScrollBarWidth); if (this.MaximumSize.Width > 0) { preferredSize.Width = Math.Min(this.MaximumSize.Width, preferredSize.Width); } return preferredSize; }
protected override void OnMeasureItem(MeasureItemEventArgs e) { // base.OnMeasureItem(e); e.ItemWidth = m_qSize; e.ItemHeight = m_qSize; }
static void MenuItem_MeasureItem(object sender, MeasureItemEventArgs e) { Font font = ((MenuItem) sender).DefaultItem ? menuBoldFont : SystemFonts.MenuFont; if (((MenuItem)sender).Text == "-") e.ItemHeight = SEPARATOR_HEIGHT; else { e.ItemHeight = ((SystemFonts.MenuFont.Height > ICON_SIZE) ? SystemFonts.MenuFont.Height : ICON_SIZE) + BORDER_VERTICAL; e.ItemWidth = LEFT_MARGIN + ICON_SIZE + RIGHT_MARGIN //item text width + TextRenderer.MeasureText(((MenuItem)sender).Text, font, Size.Empty, TextFormatFlags.SingleLine | TextFormatFlags.NoClipping).Width + SHORTCUT_MARGIN //shortcut text width + TextRenderer.MeasureText(ShortcutToString(((MenuItem)sender).Shortcut), font, Size.Empty, TextFormatFlags.SingleLine | TextFormatFlags.NoClipping).Width //arrow width + ((((MenuItem)sender).IsParent) ? ARROW_MARGIN : 0); } }
/// <summary> /// Calcul de la hauteur en pixels d'un élément de la liste /// </summary> /// <param name="e">descripteur issue d'un événement MeasureItem de l'hôte</param> /// <param name="item">référence non null sur l'item à peindre</param> public void MeasureRichItem( MeasureItemEventArgs e, RichItem item ) { // déterminer la font associée à l'item Font itemFont = item.Font; if ( itemFont == null ) itemFont = host.Font; // dimensions requises pour le texte Size textMetrics = TextRenderer.MeasureText( item.Text, itemFont ); e.ItemHeight = textMetrics.Height; e.ItemWidth = textMetrics.Width; // forcer les chaînes vides à être visibles if ( e.ItemHeight == 0 ) e.ItemHeight = (int) System.Math.Ceiling( itemFont.GetHeight( e.Graphics ) ); // assurer l'espce vertical entre les items en ce qui concerne le texte e.ItemHeight += textVSpace; // considérer l'image si nécessaire Image itemImage = host.ImageShow ? item.Image : null; if (itemImage == null) return ; // éviter de stretcher les images pour un petit nombre de pixels int imageMissing = itemImage.Height + imageVSpace - e.ItemHeight; if ( 0 < imageMissing && imageMissing < imageVStretchMin ) e.ItemHeight = itemImage.Height + imageVSpace; }
/// <summary> /// Creates a new <see>CustomMeasurements</see>. /// </summary> /// <param name="args">The <see>MeasureItemEventArgs</see> contained by this object.</param> /// <param name="itemBeingMeasured">The actual item being measured.</param> public CustomMeasurements(MeasureItemEventArgs args, object itemBeingMeasured) { Debug.Assert(!object.ReferenceEquals(args, null)); Debug.Assert(!object.ReferenceEquals(itemBeingMeasured, null)); m_args = args; m_obj = itemBeingMeasured; }
protected void OnMeasureItem(object sender, MeasureItemEventArgs e) { if (e.Index > -1 && e.Index < Items.Count) { Font myFont = new Font(this.Font.FontFamily, GetFontSize(e.Index), FontStyle.Bold); e.ItemHeight = (int)e.Graphics.MeasureString(Items[e.Index].ToString(), myFont).Height; e.ItemWidth = (int)e.Graphics.MeasureString(Items[e.Index].ToString(), myFont).Width; } }
/// <summary> /// Measure item size /// </summary> /// <param name="e"></param> protected override void OnMeasureItem(MeasureItemEventArgs e) { if (Site == null && e.Index > -1) { SizeF sizeF = e.Graphics.MeasureString(Items[e.Index].ToString(), Font, Width); e.ItemHeight = (int)sizeF.Height; e.ItemWidth = (int)sizeF.Width; } }
protected override void OnMeasureItem(MeasureItemEventArgs e) { base.OnMeasureItem(e); //製造一點空隙 e.ItemHeight = Font.Height + 5; //畫標題的時候 是畫 標題 + item 所以*2 if (IsGroupHeader(e.Index, out header)) e.ItemHeight = e.ItemHeight * 2; }
protected override void OnMeasureItem(MeasureItemEventArgs e) { base.OnMeasureItem(e); e.ItemWidth += 22; if (e.ItemHeight < 20) e.ItemHeight = 20; }
internal void MeasureItem(MeasureItemEventArgs context, object item) { if (item != null) { Size itemSize = MeasureItemCore(context, item); context.ItemWidth = itemSize.Width; context.ItemHeight = itemSize.Height; } }
void ExListBox_MeasureItem(object sender, MeasureItemEventArgs e) { if (e.Index >= this.Items.Count) return; IConfigMenuItem cfgItem = this.Items[e.Index] as IConfigMenuItem; if (cfgItem == null) return; e.ItemHeight = cfgItem.Height; }
void listBox1_MeasureItem(object sender, MeasureItemEventArgs e) { Pair<string, string> s = (Pair<string, string>)listBox1.Items[e.Index]; string[] lines = s.First.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); int count = Math.Min(lines.Length, 5) + 1; e.ItemWidth = Width; e.ItemHeight = count * listBox1.Font.Height; }
/// <summary> /// I have set the Draw property to DrawMode.OwnerDrawVariable, so I must caluclate the item measurement. /// I will set the height and width of each item before it is drawn. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ComboBox1_MeasureItem(object sender, MeasureItemEventArgs e) { var g = CreateGraphics(); var maxWidth = 0; foreach (var width in Items.ItemsBase.Cast<object>().Select(element => (int)g.MeasureString(element.ToString(), Font).Width).Where(width => width > maxWidth)) { maxWidth = width; } DropDownWidth = maxWidth + 20; }
protected override void OnMeasureItem(MeasureItemEventArgs e) { SizeF itmSize; SizeF S = new SizeF(this.Width, 0); itmSize = e.Graphics.MeasureString(this.Items[e.Index].ToString(), this.Font, S); e.ItemHeight = Convert.ToInt32(itmSize.Height); e.ItemWidth = Convert.ToInt32(itmSize.Width); }
protected override void OnMeasureItem(MeasureItemEventArgs e) { if (e.Index >= 0 && e.Index < Items.Count) { var item = Items[e.Index] as ScoredSearchResult; int h = Font.Height; if (item.RequiresPathLine) h *= 2; h += ItemMargin * 2; e.ItemHeight = h; } }
private void listBoxMessage_MeasureItem(object sender, MeasureItemEventArgs e) { var lst = (ListBoxControl) sender; var msg = (message) lst.GetItem(e.Index); int itemHeight = 0; itemHeight += (int) e.Graphics.MeasureString(msg.subject, SubjectFont, lst.Width).Height; itemHeight += (int)e.Graphics.MeasureString(msg.edu.number_sysname, FromFont, lst.Width).Height; itemHeight += (int)e.Graphics.MeasureString(msg.send_date.ToString("G"), DateFont, lst.Width).Height; e.ItemHeight = itemHeight + 32; e.ItemWidth += 24; }
void OnMeasureItem(object sender, MeasureItemEventArgs e) { if(e.Index<0||e.Index>=Items.Count) return; Bitmap bm=Items[e.Index] as Bitmap; if(bm!=null) { e.ItemWidth=bm.Width; e.ItemHeight=bm.Height; } }
public void lst_MeasureItem(object sender, MeasureItemEventArgs e) { var lst = (ListBoxControl) sender; if (e.Index >= 0) { var text = lst.GetItemText(e.Index); var textSize = TextUtils.GetStringSize(e.Graphics, text, _font, StringFormat.GenericDefault, lst.ClientRectangle.Width - 24); e.ItemHeight = textSize.Height + 5; } }
protected override void OnMeasureItem(MeasureItemEventArgs e) { if (IsItemVisible(e.Index)) { e.ItemWidth = ClientSize.Width; e.ItemHeight = 18; } else e.ItemHeight = 0; base.OnMeasureItem(e); }
protected override void OnMeasureItem(swf.MeasureItemEventArgs e) { base.OnMeasureItem(e); e.ItemHeight = (int)Math.Ceiling(Font.GetHeight(e.Graphics)) + ItemPadding * 2; var item = Items[e.Index]; var image = handler.Widget.ItemImageBinding?.GetValue(item); if (image != null) { e.ItemHeight = Math.Max(e.ItemHeight, image.Height + ItemPadding * 2); e.ItemWidth += image.Width + ItemPadding * 2; } }
void MeasureComboBoxItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { ComboBox comboBox = (ComboBox)sender; if (e.Index >= 0) { ComboBoxItem item = (ComboBoxItem)comboBox.Items[e.Index]; SizeF size = e.Graphics.MeasureString(item.ToString(), font); e.ItemWidth = (int)size.Width; e.ItemHeight = (int)Math.Max(size.Height, CodeCompletionProvider.ImagesProvider.ImageList.ImageSize.Height); } }
private void list_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { try { Font font = (Font)list.Items[e.Index]; SizeF szHeader = e.Graphics.MeasureString(font.Name, head, int.MaxValue, Format); SizeF szText = e.Graphics.MeasureString(TextValue, font, int.MaxValue, Format); // Return it e.ItemHeight = (int)(szText.Height + szHeader.Height); e.ItemWidth = (int)Math.Max(szText.Width, szHeader.Width); } catch { } }
protected override void OnMeasureItem(System.Windows.Forms.MeasureItemEventArgs e) { if (Site != null) { return; } if (e.Index > -1) { string s = Items[e.Index].ToString(); SizeF sf = e.Graphics.MeasureString(s, Font, Width); int htex = (e.Index == 0) ? 15 : 10; e.ItemHeight = (int)sf.Height + htex; e.ItemWidth = Width; } }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.ComboBox.MeasureItem"/> event. /// </summary> /// <param name="e">The <see cref="T:System.Windows.Forms.MeasureItemEventArgs"/> that was raised.</param> protected override void OnMeasureItem(MeasureItemEventArgs e) { if (e.Index < 0) return; Image bmp = this.Items[e.Index] as Image; if (bmp == null && this.Items[e.Index] as NamedImage != null) bmp = (this.Items[e.Index] as NamedImage).Image; if (bmp != null) e.ItemHeight = m_itemHeight + MARGIN * 3; else base.OnMeasureItem(e); }
private void MesureItemHandler(object sender, MeasureItemEventArgs e) { //Dim ThisMenuItem_Strings As String() = Me.Text.Split(",") SizeF TextSize = e.Graphics.MeasureString(this.Text.Replace("&", ""), CurrentFont); e.ItemWidth = System.Convert.ToInt32(TextSize.Width) + EXTRAWIDTH; if (this.Text == "-") { e.ItemHeight = SEPITEMHEIGHT; } else { e.ItemHeight = NORMALITEMHEIGHT; } e.ItemHeight = e.ItemHeight; e.ItemWidth = e.ItemWidth; }
/// We measure each item by taking the combined width of the string and bitmap, /// and the greater height of the two. private void list_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { ListBox lbSender = sender as ListBox; ToolboxItem tbi = lbSender.Items[e.Index] as ToolboxItem; Size textSize = e.Graphics.MeasureString(tbi.DisplayName, lbSender.Font).ToSize(); e.ItemWidth = tbi.Bitmap.Width + textSize.Width; if (tbi.Bitmap.Height > textSize.Height) { e.ItemHeight = tbi.Bitmap.Height; } else { e.ItemHeight = textSize.Height; } }
private void comboBox1_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { // For the comboBox with OwnerDrawVariable property // Display every second item with a height of 45 if (e.Index % 2 == 0) { e.ItemHeight = 45; e.ItemWidth = 20; } else { // Display all other items with a height of 25 e.ItemHeight = 25; e.ItemWidth = 10; } }
protected override void OnMeasureItem(System.Windows.Forms.MeasureItemEventArgs e) { //Work out what the text will be string displayText = this.Items[e.Index].ToString(); //Get width & height of string SizeF stringSize = e.Graphics.MeasureString(displayText, this.Font); //Account for top margin stringSize.Height += 5; // set hight to text height e.ItemHeight = (int)stringSize.Height; // set width to text width e.ItemWidth = (int)stringSize.Width; }
private void OnMeasureItem(object sender, MeasureItemEventArgs e) { var maxSize = new Size(); var boldFont = new Font(Font, FontStyle.Bold); using (var graphics = CreateGraphics()) foreach (var item in Items) { var text = item.ToString(); var size = graphics.MeasureString(text, favTickers.Contains(item.ToString()) ? boldFont : Font).ToSize(); if (size.Width > maxSize.Width) maxSize.Width = size.Width; if (size.Height > maxSize.Height) maxSize.Height = size.Height; } e.ItemWidth = maxSize.Width; e.ItemHeight = maxSize.Height; DropDownWidth = maxSize.Width; }
private void menuItem3_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { MenuItem item = (MenuItem)sender; Font mFont = SystemInformation.MenuFont; StringFormat stringfmt = new StringFormat(); SizeF size = e.Graphics.MeasureString(item.Text, mFont, 1000, stringfmt); e.ItemWidth = (int)Math.Ceiling(size.Width) + 10; e.ItemHeight = (int)Math.Ceiling(size.Height) + 10; }
/// <summary> /// Occurs when an element within the <see cref="ImageListBox"/> is measured. /// </summary> /// <param name="e">The <see cref="MeasureItemEventArgs"/> /// which determines the specific item to be measured.</param> protected override void OnMeasureItem(System.Windows.Forms.MeasureItemEventArgs e) { if (e.Index < base.Items.Count) { object item = base.Items[e.Index]; if (item is ImageObjectItem) { ImageObjectItem imageItem = (ImageObjectItem)item; SizeF stringSize = e.Graphics.MeasureString(imageItem.Text, this.Font); e.ItemHeight = this.GetBaseItemHeight(e.Graphics, stringSize); if (this.Style != null) { this.Style.OnMeasureItemEvent(imageItem, ref e, this.Font); } } } base.OnMeasureItem(e); }
// 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 ComboBox1_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { switch (e.Index) { case 0: e.ItemHeight = 45; break; case 1: e.ItemHeight = 20; break; case 2: e.ItemHeight = 35; break; } e.ItemWidth = 260; }
void MeasureComboBoxItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { ComboBox comboBox = (ComboBox)sender; if (e.Index >= 0) { ComboBoxItem item = (ComboBoxItem)comboBox.Items[e.Index]; SizeF size = e.Graphics.MeasureString(item.ToString(), font); e.ItemWidth = (int)size.Width; if (this.textAreaControl == null) { e.ItemHeight = (int)Math.Max(size.Height, 16); } else { e.ItemHeight = (int)Math.Max(size.Height, this.textAreaControl.AutoListIcons.ImageSize.Height); } } }
private void FontComboBox_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { if (e.Index == -1) { return; } string fontFamily = (string)this.Items[e.Index]; using (Font f = new Font(fontFamily, this.Font.Size, FontStyle.Regular)) { using (Graphics gr = this.CreateGraphics()) { e.ItemWidth = (int)gr.MeasureString(fontFamily, f).Width; e.ItemHeight = (int)gr.MeasureString(fontFamily, f).Height; } } }
public static void PopupMenu_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { MenuItem item = (MenuItem)sender; string caption = item.Text; StringFormat sf = new StringFormat(); sf.HotkeyPrefix = HotkeyPrefix.Show; Size textSize = e.Graphics.MeasureString(caption, SystemInformation.MenuFont, new PointF(0, 0), sf).ToSize(); int horizOffset = 16; e.ItemWidth = textSize.Width + horizOffset; if (item.Text != "-") { e.ItemHeight = SystemInformation.MenuHeight; } else { e.ItemHeight = 4; } }
protected override void OnMeasureItem(MeasureItemEventArgs e) { if (e.Index < 0 || e.Index >= Items.Count) { base.OnMeasureItem(e); return; } ICustomListBoxItemRenderer renderer = GetRenderer(e.Index); if (object.ReferenceEquals(null, renderer)) { base.OnMeasureItem(e); } else { CustomMeasurements measurements = new CustomMeasurements(e, Items[e.Index]); e.ItemWidth = Width; renderer.MeasureItem(measurements); } }
protected override void OnMeasureItem(MeasureItemEventArgs e) { base.OnMeasureItem(e); Font menuFont = SystemInformation.MenuFont; if (this.Text == RNaihRhYEl0wUmAftnB.aYu7exFQKN(33336)) { e.ItemWidth = 24; e.ItemHeight = 3; } else { SizeF sizeF1 = e.Graphics.MeasureString(this.Text, menuFont); SizeF sizeF2 = !this.ShowShortcut || this.Shortcut == Shortcut.None ? SizeF.Empty : e.Graphics.MeasureString(this.avOJF7XDrs(), menuFont); e.ItemWidth = 24 + (int) sizeF1.Width + (int) sizeF2.Width; e.ItemHeight = SystemInformation.MenuHeight; if (this.MenuItems.Count > 0) e.ItemWidth += 16; this.LGXJHk0oQM = (int) sizeF2.Width; } }
protected override void OnMeasureItem( MeasureItemEventArgs e ) { base.OnMeasureItem( e ); if ( e.Index != -1 ) { object item = Items[e.Index]; string text = GetDisplayText( e.Index ); if (string.IsNullOrEmpty( text )) { text = "WHOAH"; } System.Drawing.Size textSize = TextRenderer.MeasureText(text, Font ); e.ItemHeight = textSize.Height + verticalItemPadding; e.ItemWidth = textSize.Width; if ( item is SeparatorItem ) { e.ItemHeight += separatorHeight; } } }
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; } var ss = ScreenScale.Calc(); if (e.ItemHeight > Convert.ToInt32(20 * ss)) { e.ItemHeight = Convert.ToInt32(20 * ss); } } base.OnMeasureItem(e); }
protected override void OnMeasureItem(MeasureItemEventArgs e) { if (e.Index != -1) { string item = (string)this.Items[e.Index]; string itemText = getCultureName(item); Size textSize = TextRenderer.MeasureText(itemText, this.Font); object resourceFlag = Properties.Resources.ResourceManager.GetObject(item); if (resourceFlag != null && resourceFlag is Image) { Image flagImage = (Image)resourceFlag; if (flagImage.Height > textSize.Height) { textSize.Height = flagImage.Height; } textSize.Width += flagImage.Width + 2 * HORIZONTAL_PADDING; } e.ItemHeight = textSize.Height + 2 * HORIZONTAL_PADDING; e.ItemWidth = textSize.Width + 2 * HORIZONTAL_PADDING; } }
internal static void MeasureComboItem(object sender, MeasureItemEventArgs e) { if (e.Index == -1) { return; } ComboBox combo = sender as ComboBox; if (combo != null) { object comboBoxItem = combo.Items[e.Index]; Size textSize = TextRenderer.MeasureText(comboBoxItem.ToString(), combo.Font); e.ItemHeight = textSize.Height + VerticalItemPadding; e.ItemWidth = textSize.Width; if (comboBoxItem is SeparatorItem) { // one white line, one dark, one white. e.ItemHeight += SeparatorHeight; } } }
protected override void OnMeasureItem(System.Windows.Forms.MeasureItemEventArgs e) { if (this.Visible) { base.OnMeasureItem(e); StringFormat strfmt = new StringFormat(); strfmt.HotkeyPrefix = HotkeyPrefix.Show; SizeF sizef = e.Graphics.MeasureString(this.Text, this.m_font, 1000, strfmt); e.ItemWidth = (int)Math.Ceiling(sizef.Width); e.ItemHeight = 17; // Add scale adjusted width. e.ItemWidth += (int)Math.Ceiling(SystemInformation.MenuCheckSize.Width * (double)e.ItemHeight / SystemInformation.MenuCheckSize.Height); // Comment out this line if the menu group does not contain any standard MenuItems //e.ItemWidth -= SystemInformation.MenuCheckSize.Width; e.ItemWidth += (int)Math.Ceiling(m_image.Width * (double)e.ItemHeight / m_image.Height); } }
protected override void OnMeasureItem(MeasureItemEventArgs e) { if (e.Index >= this.Items.Count || e.Index < 0) { return; } Story story = this.Items[e.Index] as Story; if (story == null) { return; } string nameText, bodyText, timeText; Font boldFont = new Font(this.Font.FontFamily, this.Font.Size, FontStyle.Bold); if (story.StoryProperty != null) { bodyText = story.StoryProperty; SizeF stringSize = e.Graphics.MeasureString(bodyText, this.Font, this.Width); e.ItemHeight = (int)stringSize.Height; } else { nameText = story.FromName; bodyText = String.Concat(story.Message, "\r\n", story.LinkName); timeText = story.CreateTime.ToString("HH:mm"); SizeF nameTextSize = e.Graphics.MeasureString(nameText, boldFont, this.Width); SizeF bodyTextSize = e.Graphics.MeasureString(bodyText, this.Font, this.Width); SizeF timeTextSize = e.Graphics.MeasureString(timeText, this.Font, this.Width); e.ItemHeight = (int)nameTextSize.Height + (int)bodyTextSize.Height + (int)timeTextSize.Height + 5; /* int totalHeight = TextRenderer.MeasureText(nameText, boldFont).Height; totalHeight += 5; totalHeight += TextRenderer.MeasureText(bodyText, this.Font).Height; totalHeight += 5; totalHeight += TextRenderer.MeasureText(timeText, this.Font).Height; e.ItemHeight = totalHeight;*/ } }
private void IconMenuItem_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { int imageWidth = this.imgWidth + this.imageTextBorderPadding; int imageHeight = 0; if (this.img != null) { imageWidth = this.imgWidth + this.imageTextBorderPadding; imageHeight = this.imgHeight; } // calculate height if (imageHeight > this.font.Height) { e.ItemHeight = imageHeight; } else { e.ItemHeight = this.font.Height + this.heightPadding; } // calculate width e.ItemWidth = imageWidth + (int)e.Graphics.MeasureString(this.Text, this.font).Width; }
/// <summary> /// Handler for the editors ListBox.MeasureItem event /// </summary> /// <param name="sender">The object that raised the event</param> /// <param name="e">A MeasureItemEventArgs that contains the event data</param> private void listbox_MeasureItem(object sender, MeasureItemEventArgs e) { this.OnMeasureItem(e); }
private void ListBoxMeasureItem(object sender, Form.MeasureItemEventArgs e) { var item = _listBox.Items[e.Index] as Item; e.ItemHeight = (int)e.Graphics.MeasureString(item.TightDescription, _font).Height + 1; }
private void ListBox1_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { e.ItemHeight = dpicalc(this, 40); }
// this is never called.... protected override void OnMeasureItem(System.Windows.Forms.MeasureItemEventArgs e) { }
internal void PerformMeasureItem(MeasureItemEventArgs e) { OnMeasureItem(e); }
protected void event_color_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { //Random ColourRnd = new Random(); //Set A Random value //e.ItemHeight = ColourRnd.Next(20, 40); e.ItemHeight = 20; }
// Функция, устанавливающая размер для элемента списка private void listBox1_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { e.ItemHeight = 30; }
private void CustomMeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { e.ItemHeight = HEIGHT - 7; }
private void list_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { }
protected override void OnMeasureItem(System.Windows.Forms.MeasureItemEventArgs e) { e.ItemHeight = Dpi.ScaleY(16); }
private void comboBox4_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { //设置列表项宽 e.ItemHeight = this.comboBox4.ItemHeight - 2; }
private void MenuItem_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { e.ItemWidth = Width - 18; //not sure why I have to subtract 18 to make it the proper width. e.ItemHeight = 14; }
void ComboBoxMeasureItem(object sender, MeasureItemEventArgs mea) { if (mea.Index < 0 || mea.Index >= comboBox.Items.Count) { mea.ItemHeight = comboBox.Font.Height; return; } object item = comboBox.Items[mea.Index]; SizeF size = mea.Graphics.MeasureString(item.GetType().ToString(), comboBox.Font); mea.ItemHeight = (int)size.Height; mea.ItemWidth = (int)size.Width; if (item is IComponent) { ISite site = ((IComponent)item).Site; if (site != null) { string name = site.Name; using (Font f = new Font(comboBox.Font, FontStyle.Bold)) { mea.ItemWidth += (int)mea.Graphics.MeasureString(name + "-", f).Width; } } } }
protected virtual void OnMeasureItem(MeasureItemEventArgs e) { MeasureItemEventHandler eh = (MeasureItemEventHandler)(Events[MeasureItemEvent]); if (eh != null) eh(this, e); }
private void OnMeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { e.ItemHeight = 26; }
/// <summary> /// Standard MeasureItem EventHandler for ListBox lbHatchStyles. /// </summary> /// <param name="sender">Standard sender object.</param> /// <param name="e">Standard MeasureItemEventArgs object.</param> private void lbHatchStyles_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { e.ItemHeight = iHatchStyleBoxWidth + 2 * iItemPadY; e.ItemWidth = lbHatchStyles.ClientRectangle.Width; }