i saw this article that shows printing of listview using printdocument.. it helps me but then i want to place my list view on the middle of the page.. i want to know how to place it.. can you please help me? thank youu. !

You have to calculate 2 things:
1. the dimensions of the form
2. the dimensions of the control (listView in your case)

Then calculate to position it in the middle.
So you can do:

int formX = this.Width;
int formY = this.Heigth;
int listX = listView1.Width
int listY = listView1.Heigth;

int X = (formX / 2) - (listX / 2);
int Y = (formY / 2) - (listY / 2);

listView1.Location = new Point(X, Y);

Mitja - is this a VB.net code???

i think its not vb.net code.. it has errors.

i change to this >> Dim formX As Integer = this.Width

but then have errors in
this.width

ups, sorry, this is VB`s code:

Dim formX As Integer = Me.Width
Dim formY As Integer = Me.Height
Dim listX As Integer = listView1.Width
Dim listY As Integer = listView1.Height

Dim X As Integer = (formX \ 2) - (listX \ 2)
Dim Y As Integer = (formY \ 2) - (listY \ 2)

listView1.Location = New Point(X, Y)

thanx for the code.. but when i put it my PrintDocument .. the listbox in my form disappears .. and the listbox in my printpreview dialogbox stills in the top of the page. .. how should i adjust it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.