Can't find what you're looking for?

Contact us or post in our forums and we'll help you find an answer.

Print/preview selected rows in TrueDBGrid

Background:

How to print/preview selected rows in TrueDBGrid

Steps to Complete:

1. Create a new TrueDBGrid and add it to the form.

C1TrueDBGrid tdb = new C1TrueDBGrid();
Controls.Add(tdb);
tdb.Visible = false;

2. Add selected Rows to the new TrueDBGrid.

for (int c = 0; c < c1TrueDBGrid1.Columns.Count; c++)
{
tdb.Columns.Add(new C1DataColumn(c1TrueDBGrid1.Columns[c].Caption, c1TrueDBGrid1.Columns[c].DataType));
}

tdb.SetDataBinding();

for (int r = 0; r < c1TrueDBGrid1.SelectedRows.Count; r++)
{
DataRow dr;
dr = ((c1TrueDBGrid1.DataSource as DataTable).Rows[c1TrueDBGrid1.SelectedRows[r]]);
tdb.Rows.Add(dr.ItemArray);
}

3. Preview that new TrueDBGrid.

tdb.PrintInfo.PrintPreview();
Get the Latest Version of WinForms Edition
Download the Free Trial Now