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

Printing settings for Grid

I want to print the grid with no gridlines, with a preset background and text color. setting : this.gridControl1.BackColor = Color.White; this.gridControl1.ForeColor = Color.Black; this.gridControl1.Properties.DisplayHorzLines = false; this.gridControl1.Properties.DisplayVertLines = false; does not make a difference - it sets only the BackColor. ForeColor does not work at all, and gridlines are not displayed in Grid itself, but are shown in Print Preview (and are also visible on the printed document). How can I make this work? :-\

8 Replies

AD Administrator Syncfusion Team July 31, 2003 09:04 AM UTC

Below is code that I think will display black and white like your sample code. If you want different textcolor and background than B&W, then you will have to set grid.BaseStylesMap["Standard"].StyleInfo.TextColor (and BackColor). grid.BeginUpdate(); grid.Properties.BlackWhite = true; grid.Properties.DisplayHorzLines = false; grid.Properties.DisplayVertLines = false; GridBorderStyle border = grid.DefaultGridBorderStyle; grid.DefaultGridBorderStyle = GridBorderStyle.None; GridPrintDocument pd = new GridPrintDocument(gridControl1, true); PrintPreviewDialog dlg = new PrintPreviewDialog() ; dlg.Document = pd; ((Form)dlg).WindowState = FormWindowState.Maximized; dlg.ShowDialog(); grid.Properties.BlackWhite = false; grid.Properties.DisplayHorzLines = true; grid.Properties.DisplayVertLines = true; grid.DefaultGridBorderStyle = border; grid.EndUpdate();

NP Nick Pasko August 6, 2003 06:14 AM UTC

The problem is - with grid.Properties.BlackWhite set true grid does not show any colors but black and white (and, as i could see, it shows the text in black even if the text color is white). And I need to fill some cells with colors (and I don't care they will be printed uncolored, i want them to be seen and differ from black AND white. My current prob is if BlackWhite is set to false - grid somehow displays a system default text color, which is set to green on my PC. So, after printing it is really troublesome to read the text. Is there any way to set the TextColor (or ForeColor, i don't care) for the entire grid, not every single cell?

AD Administrator Syncfusion Team August 6, 2003 06:17 AM UTC

You can set the default TextColor for a grid by setting it in the standard style. this.grid.BaseStylesMap["Standard"].StyleInfo.TextColor = Color.Red;

NP Nick Pasko August 6, 2003 08:20 AM UTC

Thanks! :) One additional question - how do I remove a border which is still printed?

AD Administrator Syncfusion Team August 6, 2003 09:18 AM UTC

If a border is still being displayed after the previous code, then this border must be explicitly set in some style object. In this case, you would have to call style.Borders.ResetAll() to make the borders used the default border style which you set to None. Or, the border is being drawn because of something else. For example,if it is a rowheader, then the default behavior is to draw these 3d which gives the solid line on the right and bottom of the cell which looks like a gridline. In this case, you some how have to prevent the drawing, maybe: this.gridControl1.BaseStylesMap["Row Header"].StyleInfo.CellType = "Static"; which makes the row headers static cells instead of header cells.

NP Nick Pasko August 7, 2003 12:37 AM UTC

Ouch, there seems to be a misunderstanding, probably due to my bad English.. I meant the GRID border, outlining the whole GRID, not the CELL border.

AD Administrator Syncfusion Team August 7, 2003 05:50 AM UTC

There is a property setting that controls whether that frame is printed. grid.Properties.PrintFrame = false;

NP Nick Pasko August 13, 2003 06:06 AM UTC

Thanks again!

Live Chat Icon For mobile
Up arrow icon