For the selections problem, you will have to change the range types form row ranges ot cell ranges. Below is button handler code to do this.
If you want to PRINT from some page to some page, you can try to use the AllowSomePages member of teh PrintDialog. The PrintPrevievDialog does not have this member. Below is a modififed button handler. I am not sure it works as I currently do not have access to a printer.
private void button2_Click(object sender, System.EventArgs e)
{
//selected
if (this.gridDataBoundGrid1 != null)
{
if(this.gridDataBoundGrid1.Selections.Count == 0)
{
MessageBox.Show("Select some cells first.");
return;
}
GridRangeInfoList rangeList = new GridRangeInfoList();
foreach(GridRangeInfo range in this.gridDataBoundGrid1.Selections)
{
if(!range.IsCells)
rangeList.Add(range.ExpandRange(1, 0, this.gridDataBoundGrid1.Model.RowCount, this.gridDataBoundGrid1.Model.ColCount) );
else
rangeList.Add((GridRangeInfo)range.Clone());
}
this.gridDataBoundGrid1.Selections.Clear(false);
foreach(GridRangeInfo range in rangeList)
this.gridDataBoundGrid1.Selections.Add(range);
GridPrintDocument pd = new GridPrintDocument(this.gridDataBoundGrid1, true);
pd.PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.Selection;
PrintPreviewDialog dlg = new PrintPreviewDialog() ;
dlg.Document = pd;
dlg.ShowDialog();
}
}
private void button3_Click(object sender, System.EventArgs e)
{
if (this.gridDataBoundGrid1 != null)
{
GridPrintDocument pd = new GridPrintDocument(this.gridDataBoundGrid1);
PrintDialog dlg = new PrintDialog() ;
dlg.Document = pd;
dlg.AllowSomePages = true;
if(dlg.ShowDialog() == DialogResult.OK)
{
pd.Print();
}
}
}