PrintDocument doc = new PrintDocument(); PrintDialog printDialog = new PrintDialog(); if (printDialog.ShowDialog() == DialogResult.OK) { //Event Triggering doc.PrintPage += Pd_PrintPage; doc.Print(); } //Event Customization private void Pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { //To draw the grid in print document this.gridControl1.DrawGrid(e.Graphics); } |
perfect! That is exactly what i needed. Somehow i missed the DrawGrid function when reading through the documentation.
Thank you very much!
on a somewhat related note, is it possible to serialize a gridcontrol's properties but not its data so that i could load data into the grid and then load the serialized settings but keep the new data?
thanks.
XmlWriter xmlWriter = new XmlWriter("BaseLandF.xml");
this.gridGroupingControl1.WriteXmlLookAndFeel(xmlWriter); |
XmlReader xmlReader = new XmlReader("BaseLandF.xml");
this.gridGroupingControl1.ApplyXmlLookAndFeel(xmlReader); |
Thank you very much for that info. Before I attempt to recreate all of the grid controls I am using in my application (there are quite a few) to tye grouping control, let me ask you this: about how difficult and time consuming is it to recreate a grid control to a gridgroupingcontrol with the same visual styles, colors, etc.?
It seems as though the grid grouping control is a good but different than the Gridcontrol in terms of the code behind, and considering the large number of grids im dealing with i tbink i will just rethink my method of filling the data when the xml properties are loaded.
I would recommend that Syncfusion consider making it possible to serialize the properties only (no data) of the gridcontrol in the future as it would make the control that much more dynamic.
Thank you for your help.
//To Serialize the Style private void serializeBtn_Click(object sender, EventArgs e) { Stream s = File.Create("GridStyle"); XmlWriter xmlWriter = new XmlTextWriter(s, Encoding.Default); //To serialize the Columns XmlSerializer xmlSerializer = new XmlSerializer(typeof(GridStyleInfo)); xmlSerializer.Serialize(xmlWriter, this.gridControl1.Model.ColStyles[3]); ////To serialize the base style //XmlSerializer xmlSerializer = new XmlSerializer(typeof(GridBaseStyle)); //xmlSerializer.Serialize(xmlWriter, this.gridControl1.Model.BaseStylesMap.Standard); ////To serialize the rowstyle //XmlSerializer xmlSerializer = new XmlSerializer(typeof(GridStyleInfo)); //xmlSerializer.Serialize(xmlWriter, this.gridControl1.Model.RowStyles[5]); s.Close(); } //To deserialize the style private void button2_Click(object sender, EventArgs e) { Stream s = File.OpenRead("GridStyle"); XmlReader xmlReader = new XmlTextReader(s); //To deserialize the column styles alone XmlSerializer xmlSerializer = new XmlSerializer(typeof(GridStyleInfo)); this.gridControl1.Model.ColStyles[3] = (GridStyleInfo)xmlSerializer.Deserialize(xmlReader); ////To deserialize the basestyle //XmlSerializer xmlSerializer = new XmlSerializer(typeof(GridBaseStyle)); //this.gridControl1.Model.BaseStylesMap.Standard = (GridBaseStyle)xmlSerializer.Deserialize(xmlReader); ////To deserialize the rowstyles alone //XmlSerializer xmlSerializer = new XmlSerializer(typeof(GridStyleInfo)); //this.gridControl1.Model.RowStyles[5] = (GridStyleInfo)xmlSerializer.Deserialize(xmlReader); s.Close(); this.gridControl1.Refresh(); } |