Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
I have following requirement:
When we click on the Print button for data table. It should show the view to be printed.
Our requirement is to hide some unnecessary column.

Kindly suggest.
Posted
Comments
Praveen Kumar Upadhyay 16-Apr-15 6:05am    
Please change your tag. It should not be under datatable. Also improve your question, provide which database you are using, what is the tool, how you are printing.
Maciej Los 16-Apr-15 7:19am    
Print where? What you mean by "unnecessary column"?
raghunath sahoo 16-Apr-15 7:53am    
I have 24 columns. If I use Print functionality of the data table, then I see 24 columns in the print preview. I do not need 4 columns from end. So once I click on Print i should be able to see 20 columns.

1 solution

I'd suggest to use PrintDocument class[^]. Here you'll find bit more details: Print DataSet or DataTable contents from VB.NET[^]

Note that number of coulumns to print is defined here:
VB
aNumColumns = myDataSet.Tables(aTblIndex).Columns.Count - 1

With myDataSet.Tables(aTblIndex)
    For aCol = 0 To aNumColumns


You need to change above code to your needs as follow:
VB
aNumColumns = DataTable1.Columns.Count - 5

With DataTables1
    For aCol = 0 To aNumColumns
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900