resize datagrid in vb.net very urgent !!!!!! - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

resize datagrid in vb.net very urgent !!!!!!

aswinanuaswinanu Posts: 13Member
hi,
I am aswin ,i am doing a project in vb.net sql server
i want to resize my datagrid during the run time according to the information it contains .please send the details of this subject
very urgent !!!!!!!!!!1

Comments

  • DrMartenDrMarten Posts: 748Member
    [b][red]This message was edited by DrMarten at 2007-1-7 15:44:43[/red][/b][hr]

    : hi,
    : I am aswin ,i am doing a project in vb.net sql server
    : i want to resize my datagrid during the run time according to the information it contains .please send the details of this subject
    : very urgent !!!!!!!!!!1
    ---------------------------------------------------------------------

    Hi,

    You will have to experiment with sizes for your data however
    here is some code for you to play with some of the size properties.

    Remember to set the TOP and LEFT in your properties window AND
    in your code so the DataGrid doesn't physically move.

    [code]
    Private Sub DataGrid1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.Click
    Dim mySize As System.Drawing.Size[b][green]
    'Set a size of 200 by 200.[/green][/b]
    mySize.Height = 200
    mySize.Width = 200
    DataGrid1.Size = mySize[b][green]
    'Set the column width and height in pixels.[/green][/b]
    DataGrid1.PreferredColumnWidth = 20
    DataGrid1.PreferredRowHeight = 20[b][green]
    'Scale the DataGrid.[/green][/b]
    DataGrid1.Scale(1.2)[b][green]
    'or use two numbers to scale it by width and height.[/green][/b]
    DataGrid1.Scale(1.2, 1.5)[b][green]
    'Keep the top and left at 100 pixels down and from the left.[/green][/b]
    DataGrid1.Top = 100
    DataGrid1.Left = 100
    End Sub
    [/code]

    I've just thought, as it is the text mostly that changes then you
    could use a scrollbar to scale the width of the DataGrid, or as well as the column width only. :-)
    Use the following with a scrollbar just above or below your DataGrid,
    however you like it.>>

    [code]
    Private Sub HScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.Scroll

    Dim mySize As System.Drawing.Size
    HScrollBar1.Minimum = 1
    HScrollBar1.Maximum = 500
    Dim myVal As Integer
    myVal = HScrollBar1.Value
    mySize.Width = myVal
    DataGrid1.Width = myVal
    DataGrid1.Top = 100
    DataGrid1.Left = 100

    End Sub
    [/code]

    You could add a 2nd scrollbar to adjust the
    height using a VscrollBar in a similiar way. ;-)

    Another Hscrollbar could adjust the columnWidth. :-)



    Regards,

    Dr M.

Sign In or Register to comment.