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

Cell text gets cut off

Thread ID:

Created:

Updated:

Platform:

Replies:

69469 Oct 29,2007 05:23 PM UTC Nov 7,2007 04:01 PM UTC WinForms 8
loading
Tags: GridControl
Omar
Asked On October 29, 2007 05:23 PM UTC

Hi,

When I print the grid, the full text of the cell does not print, even though it displays ok as I use the ResizeToFit function.

I have attached a smaple indicating hte problem, the last letter is getting cut.

Thanks.

Omar
Replied On October 29, 2007 05:24 PM UTC

attached:


Syncfusion.zip

J.Nagarajan [Syncfusion]
Replied On October 30, 2007 11:04 PM UTC

Hi MC ,

one way you can do this by handling the QueryColWidth event and set the size of column when grid is in printmode. Please refer to the following code snippet

[VB]

Dim FirstColWidth As Integer = -1
Private Sub Grid_QueryColWidth(ByVal sender As System.Object, ByVal e As syncfusion.Windows.Forms.Grid.GridRowColSizeEventArgs) Handles Grid.QueryColWidth
If e.Index > 0 And Me.Grid.PrintingMode() Then
e.Handled = True
e.Size = FirstColWidth + 5
End If
End Sub


I have attached the sample for your reference. You can download the sample from the following page.
http://websamples.syncfusion.com/samples/Grid.Windows/F69469/main.htm

Please refer to the sample and let me know if this helps.

Best Regards,
Nagaraj


Omar
Replied On October 31, 2007 03:39 PM UTC

Thanks for your reply.

In reality I have more than 1 column, so I guess I need to change the width of every column by 5 to be safe. Is there a way to do this through handling the QueryColWidth event only?

I have attached a sample showing the updated problem.

Thanks.


Syncfusion.zip

haneefm [Syncfusion]
Replied On November 1, 2007 08:01 PM UTC

Hi MC,

Another way you can do this by handling the DrawCellDisplayText event of the grid and change the width of the TextRectangle. Below are the code that shows this task.

Private Sub Grid_DrawCellDisplayText(ByVal sender As System.Object, ByVal e As syncfusion.Windows.Forms.Grid.GridDrawCellDisplayTextEventArgs) Handles Grid.DrawCellDisplayText
If e.ColIndex > 0 And Me.Grid.PrintingMode Then
e.Cancel = True
Dim rect As Rectangle = e.TextRectangle()
rect.Width = rect.Width + 5
GridStaticCellRenderer.DrawText(e.Graphics, e.DisplayText, e.Style.GdipFont, rect, e.Style, e.Style.TextColor, e.Style.RightToLeft = System.Windows.Forms.RightToLeft.Yes)
End If
End Sub

Here is a modified sample for your reference.
ModifiedSyncfusion.zip

Best regards,
Haneef

Omar
Replied On November 5, 2007 09:43 PM UTC

Hi,

Thanks for your reply, but even this does not work. Obviously, this is a bug (please acknowledge it as such).

The problem now is that the last column will get off on a wider grid, I believe the grid.width remains the same but the indiviudal column width will be greater and not enough space is left for the last column.

Jisha Joy [Syncfusion]
Replied On November 6, 2007 10:00 AM UTC

Hi,

Thank you for the update.

It is a default behavior that the grid control width is not increasing when we increase the individual coulmn width. The mentioned issue can be avoided by increasing the grid width when we increase the column width.

Private Sub Grid_DrawCellDisplayText(ByVal sender As System.Object, ByVal e As syncfusion.Windows.Forms.Grid.GridDrawCellDisplayTextEventArgs) Handles Grid.DrawCellDisplayText
If e.ColIndex > 0 And Me.Grid.PrintingMode Then
e.Cancel = True
Dim rect As Rectangle = e.TextRectangle()
rect.Width = rect.Width + 5
Grid.Width = Grid.Width + 5
GridStaticCellRenderer.DrawText(e.Graphics, e.DisplayText, e.Style.GdipFont, rect, e.Style, e.Style.TextColor, e.Style.RightToLeft = System.Windows.Forms.RightToLeft.Yes)
End If
End Sub
End Class


Please refer the modified sample:
http://websamples.syncfusion.com/samples/Grid.Windows/69469/main.htm

Please try this and let me know if this helps.

Regards,
Jisha

Omar
Replied On November 6, 2007 02:17 PM UTC

It doesn't work because the Grid.Width doesn't change when I do Grid.Width = Grid.Width + 5 in this event.

But none of this should need to be done in the 1st place, the cell text shouldn't be getting cut-off in print mode.



haneefm [Syncfusion]
Replied On November 7, 2007 04:01 PM UTC

Hi MC,

Sorry for the delay on this issue.

The reason for getting this issue is that your problem is related to the GraphicsUnit specified for a font.

When you print the grid the text in cells might for example be clipped differently than when it is displayed. This is because the font is device dependent. GridFontInfo.Unit lets you change this.

If you need to have the grid clip text in cells device-independent, thus making the print output look exactly the same as screen output you should specify GraphicsUnit.World for of the standard styles object.

In the following code snippet, the GraphicsUnit for standard font for a grid control is change to GraphicsUnit.World.

GridStyleInfo standard = Grid.Model.BaseStylesMap["Standard"].StyleInfo;
Font dfont = Control.DefaultFont;
standard.Font.Unit = GraphicsUnit.World;
standard.Font.Facename = dfont.Name;
standard.Font.Size = GridFontInfo.SizeInWorldUnit(dfont);

Here is a modified sample for your reference.
ModifiedGraphicUnitPrint.zip

Thanks for your patience.

Best regards,
Haneef


CONFIRMATION

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

;