private void someLabel_Paint(object sender, PaintEventArgs e) { // This code requires a ToolTip control on the form named toolTip. Label thisLabel = sender as Label; // Set a rectangle size with same width and larger height than label's. SizeF layoutSize = new SizeF(thisLabel.Width, thisLabel.Height + 1); // Get the actual size of rectangle needed for all of text. SizeF fullSize = e.Graphics.MeasureString(thisLabel.Text, thisLabel.Font, layoutSize); // Set a tooltip if not all text fits in label's size. if (fullSize.Width > thisLabel.Width || fullSize.Height > thisLabel.Height) { toolTip.SetToolTip(thisLabel, thisLabel.Text); } else { toolTip.SetToolTip(thisLabel, null); } }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.