How can i set screen height based on resolution ? and i have a gridview in my page.when screen height is 768 page size of gridview is 7.
screen height is 864 page size of gridview is 10.
screen height is 960 page size of gridview is 11.
screen height is 1024 page size of gridview is 12.

how to do?

You get screen's height with:

Dim DisplayRect As Rectangle
DisplayRect = Screen.PrimaryScreen.Bounds
MessageBox.Show("Screen Height=" & DisplayRect.Height, "Height", MessageBoxButtons.OK, MessageBoxIcon.Information)

and the usable area (without Taskbar):

Dim ScreenRect As Rectangle
ScreenRect = My.Computer.Screen.WorkingArea
MessageBox.Show("WorkingArea Height=" & ScreenRect.Height, "Height", MessageBoxButtons.OK, MessageBoxIcon.Information)

I didn't quite understand your question. If possible, forget screen resolutions, put your gridview in the form and resize gridview control in form's resize event.

how can i resize gridview control in form's resize event.

give me code
pls it urgent

First, if gridview is your only control in form you may also use:

DataGridView1.Dock = DockStyle.Fill

which makes control use all the available area and "automatically" resizes itself with form.

You may also try SplitContainer control which has Panel container controls. You can place gridview in one panel and other controls to second panel. SplitContainer can also contain another SplitContainer control. Also TableLayoutPanel control offers a nice way to organize your controls. They all have Dock property mentioned above. You may want to experience and play around with both SplitContainer and TableLayoutPanel controls. They are really handy container controls to organize your form's layout.

Here's a skeleton for resize event:

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
    '
    ' Resize controls

    ' I usually set minimum width & height to forms
    If Me.Width < 500 Then
      Me.Width = 500
    End If
    If Me.Height < 400 Then
      Me.Height = 400
    End If

    ' Set control's top & left positions
    DataGridView1.Top = 8
    DataGridView1.Left = 8

    ' Set control's height & width (here with fixed values)
    DataGridView1.Height = 200
    DataGridView1.Width = 300

    ' Alternatively, calculate from current form's size ("Me" refers to this form)
    ' If you have MenuBar, StatusBar or similar you can't have simple DataGridView1.Height = Me.Height
    DataGridView1.Height = Me.Height - 80 ' Set 80 pixels lower than form's height
    DataGridView1.Width = Me.Width - 16 ' Set 16 pixels wide, if DataGridView1.Left = 8 then DataGridView1 should be now horizontally centered in the form

End Sub

You can try this code and adjust values to get a nice "look". If you have other controls, you have to reposition them too in a similar way.

Since you may set easily "illegal" (negative) values for Height and Width you should use Try...Catch...End Try blocks when setting values.

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.