We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Class for Grid Cell Inplace Tooltip

The syncfusion grid doesn't currently have an inplace tooltip for cells which are too narrow for the text they contain, as in the Microsoft property controls. The tooltip control can provide a displaced tooltip, but this looks terrible. This class provides this functionality: // The the form class: private GridTextExtender m_oGridTextExtender = null; // On form load: m_oGridTextExtender = new GridTextExtender (this); // In the grid's MouseMove event handler: private void grid_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { m_oGridTextExtender.Show(grid, new Point(e.X, e.Y)); } And that's it.. Enjoy...

5 Replies

RM Rob Munn July 3, 2003 10:07 PM UTC

Here's the VB version...

AD Administrator Syncfusion Team July 5, 2003 08:36 PM UTC

Hi, I had discussion with Clay recently regarding these auto cell tooltips. http://www.syncfusion.com/forums/message.asp?MessageID=5201 I have added the code that Clay sent in my app. But, I think it is very good idea to incorporate somekind of auto-cell-tooltips-when-text-is-cutoff into 2.0 release. What do you guys think? thanks, - Reddy

AD Administrator Syncfusion Team July 5, 2003 09:00 PM UTC

We'll add that for sure, but it might have to wait for a point release after 2.0. There are many minor things that we want to add, but first we need to focus on the big features like hierarchies and grouping be implemented on top of the existing code base before we then go in and add such usability features. The cell tips for cut-off text is definitely on our TODO list. Several people indicated they would like to see that. Other suggestion and feature requests are all welcome. Your user feedback helps us with prioritizing what features should be implemented first. Thanks also for sharing that workaround with others! Stefan

RM Rob Munn July 10, 2003 10:38 PM UTC

To fix a bug in the C# GridTextExtender class to correctly position the extender label in a grid that's been scolled down, replace the code in method ShowExtendedText(...) with the following: private void ShowExtendedText(Syncfusion.Windows.Forms.Grid.GridControl oGrid, int nRow, int nCol) { // Set the label text and width Graphics oGraphics = oGrid.CreateGraphics(); GridStyleInfo oStyle = oGrid[nRow, nCol]; float fTextWidth = oGraphics.MeasureString(oStyle.Text, oStyle.GdipFont).Width; oGraphics.Dispose(); m_oLabel.Text = oStyle.Text; m_oLabel.Size = new System.Drawing.Size((int)fTextWidth + 5, oGrid.DefaultRowHeight - 1); // Compute the cell location Point oCellPoint = oGrid.ViewLayout.ClientRowColToPoint(oGrid.ViewLayout.RowIndexToVisibleClient(nRow), oGrid.ViewLayout.ColIndexToVisibleClient(nCol)); Point oScreenPoint = oGrid.PointToScreen(oCellPoint); Point oFormPoint = m_oLabel.Parent.PointToClient(oScreenPoint); // Allow for text margins and then fine tune (if oStyle.TextMargins are 1, then // this code is a bit redundant) oFormPoint.X += oStyle.TextMargins.Left - 1; oFormPoint.Y += oStyle.TextMargins.Top - 1; // Set the label to computed position m_oLabel.Location = oFormPoint; m_oLabel.Visible = true; m_oLabel.Font = oGrid.Font; m_oLabel.BringToFront(); }

AD Administrator Syncfusion Team July 11, 2003 05:23 AM UTC

Here's some VB code for the method Robb posted.
Private Sub ShowExtendedText(oGrid As Syncfusion.Windows.Forms.Grid.GridControl, nRow As Integer, nCol As Integer)
   ' Set the label text and width
   Dim oGraphics As Graphics = oGrid.CreateGraphics()
   Dim oStyle As GridStyleInfo = oGrid(nRow, nCol)
   Dim fTextWidth As Single = oGraphics.MeasureString(oStyle.Text, oStyle.GdipFont).Width
   m_oLabel.Text = oStyle.Text
   m_oLabel.Size = New System.Drawing.Size(CInt(fTextWidth) + 5, oGrid.DefaultRowHeight - 1)
   ' Compute the cell location 
   Dim oCellPoint As Point = oGrid.ViewLayout.ClientRowColToPoint(oGrid.ViewLayout.RowIndexToVisibleClient(nRow), oGrid.ViewLayout.ColIndexToVisibleClient(nCol))
   Dim oScreenPoint As Point = oGrid.PointToScreen(oCellPoint)
   Dim oFormPoint As Point = m_oLabel.Parent.PointToClient(oScreenPoint)
   ' Allow for text margins and then fine tune (if oStyle.TextMargins are 1, then
   ' this code is a bit redundant)
   oFormPoint.X += oStyle.TextMargins.Left - 1
   oFormPoint.Y += oStyle.TextMargins.Top - 1
   ' Set the label to computed position
   m_oLabel.Location = oFormPoint
   m_oLabel.Visible = True
   m_oLabel.Font = oGrid.Font
End Sub 'ShowExtendedText

Live Chat Icon For mobile
Up arrow icon