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

Feature Request: Automatic cell tool tips when text is cutoff

It would be very convenient to have an "Automatic cell level tooltip" when the text is "cut off". For example, in a data bound grid like customers, when the col widths are small, the user can hover across address cells to see what is the value in the cell with out having to adjust the cell widths. This should work with all the cell types (textbox, combobox etc.). This is similar to the Windows Explorer directory Tree with folder node tooltips when the folders pane is too narrow to show the full directory name. thanks, - Reddy

3 Replies

AD Administrator Syncfusion Team June 24, 2003 09:33 PM UTC

You might be able to get this behavior now by handling PrepareViewStyleInfo and setting CellTipText if the text will not fit in the width.
private void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
	if(e.ColIndex > 0 && e.RowIndex > 0)
		if( this.gridControl1.ColWidths[e.ColIndex] - e.Style.TextMargins.Left - e.Style.TextMargins.Right < CreateGraphics().MeasureString(e.Style.Text, e.Style.GdipFont).Width )
			e.Style.CellTipText = e.Style.Text;

AD Administrator Syncfusion Team June 25, 2003 01:03 AM UTC

Clay, Don't you think calling CreatingGraphics() for every PreviewStyleInfo() call creates lot of overhead? Do we have to dispose that graphics object? thanks, - Reddy

AD Administrator Syncfusion Team June 25, 2003 07:31 AM UTC

Oh, you wanted it to be efficient. :) I was trying to use teh CellTipText property that was added for 1.6. To do so, and be able to work with virtua grids (including GridDataBoundGrid), then the CellTipText would have to be provided dynamically either in Model.QueryCellInfo or PrepareViewStyleInfo. And yes, you might want to dispose of the Griphics object though it being cretaed on the frame like that may not really require it as it si immediately out of scope and should be processed on the next GC. I just don't know. Anyway, you can also do it using the standard Windows Forms Tooltip in a dynamic way so it works withvirtual grids without having to greate graphics objects in PrepareViewStyleInfo or QueryCellInfo. Instead, you have to create one each time you enter a new cell. I think this is about teh least you can get away with as you do have to get the string length as some point. And I think trying to store and manage string legths (instead of generating them as you need them) would be a major undertaking, especially for virtual grids. Here is code that uses a tooltip to dynamically display long text in a cell.
private ToolTip toolTip1;
private int hooverRow = -1;
private int hooverCol = -1;

private void Form1_Load(object sender, System.EventArgs e)
	this.toolTip1 = new System.Windows.Forms.ToolTip();
	toolTip1.InitialDelay = 500; //half a second delay
	toolTip1.ReshowDelay = 0;
private void gridControl1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
	int row, col;
	if(this.gridControl1.PointToRowCol(new Point(e.X, e.Y), out row, out col) 
		&& (col != hooverCol || row != hooverRow))
		hooverCol = col;
		hooverRow = row;
		if(this.toolTip1 != null && this.toolTip1.Active)
			this.toolTip1.Active = false; //turn it off

		Graphics g = CreateGraphics();
		GridStyleInfo style = this.gridControl1[row, col];
		if( this.gridControl1.ColWidths[col] - style.TextMargins.Left - style.TextMargins.Right 
				< g.MeasureString(style.Text, style.GdipFont).Width )
			this.toolTip1.SetToolTip(this.gridControl1, style.Text);
			this.toolTip1.Active = true; //make it active so it can show

Live Chat Icon For mobile
Up arrow icon