views:

202

answers:

1

Using VB.NET 2008

Am using Datagridview in my application, Datagridview should display according to the windows screen size, Before I used vb6

code.

Private Sub Form_Resize()
On Error Resume Next

    If Me.WindowState = vbMinimized Then
        Exit Sub
    End If

    listview1.Top = 1550
    listview1.Left = 0
    If ScaleHeight > 1550 Then
        listview1.Height = ScaleHeight - 1550
    End If

    listview1.Width = ScaleWidth
End Sub

Am new to vb.net, How to set a datagridview size according to windows screen size, In Datagridview property itself any option is available or i have to make a code as like vb. If i have to make a code, how to give form_resize in vb.net.

Need vb.net code Help.

A: 

I'm not sure I understand your question, but I'll give it a try. This should be pretty simple. You set the DataGridView size using the Size property. If you want it to fill the entire window you would say something like this:

Private Sub frmBar_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize

    If (Me.WindowState = FormWindowState.Minimized) Then
        Exit Sub
    End If

    dataGridView.Location = New Point(0, 0) 
    dataGridView.Size = Me.Size - New Size(4, 30) 

End Sub

But you can make it whatever size you want. All you have to do is change what you are setting for the dataGridView.Size property.

Boerema