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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Class for Grid Cell Inplace Tooltip

Thread ID:





5449 Jul 3,2003 12:06 AM Jul 11,2003 01:23 AM Windows Forms 5
Tags: GridControl
Rob Munn
Asked On July 3, 2003 12:06 AM

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...

Rob Munn
Replied On July 3, 2003 06:07 PM

Here's the VB version...

Administrator [Syncfusion]
Replied On July 5, 2003 04:36 PM

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

Administrator [Syncfusion]
Replied On July 5, 2003 05:00 PM

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

Rob Munn
Replied On July 10, 2003 06:38 PM

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(); }

Administrator [Syncfusion]
Replied On July 11, 2003 01:23 AM

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


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon