By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,165 Members | 1,429 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,165 IT Pros & Developers. It's quick & easy.

Datagrid, Anchor and Form Load

P: n/a
I have a datagrid that I create dynamically in code and want it to
appear when a link label is clicked.

The form loads in maximized view.

When the datagrid appears though I have anchored it to right, left, top
and bottom the grid appears sized as if it were still at normal view. If
I size it down it gets even smaller.

How can I when the form loads in maximized view, tell it to anchor and
have it anchor to the edges as I asked for?

Nov 21 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
"scorpion53061" schrieb
I have a datagrid that I create dynamically in code and want it to
appear when a link label is clicked.

The form loads in maximized view.

When the datagrid appears though I have anchored it to right, left, top
and bottom the grid appears sized as if it were still at normal view. If
I size it down it gets even smaller.

How can I when the form loads in maximized view, tell it to anchor and
have it anchor to the edges as I asked for?


Code please.

Cheers

Arne Janning
Nov 21 '05 #2

P: n/a
Kelly,

Did you maybe placed in on a panel or something it anchors to its parent.

When you want to anchor it to the edge, than is the Dock in my opinion much
nicer

Cor

"scorpion53061".
I have a datagrid that I create dynamically in code and want it to
appear when a link label is clicked.

The form loads in maximized view.

When the datagrid appears though I have anchored it to right, left, top
and bottom the grid appears sized as if it were still at normal view. If
I size it down it gets even smaller.

How can I when the form loads in maximized view, tell it to anchor and
have it anchor to the edges as I asked for?

Nov 21 '05 #3

P: n/a
Create a form.

Tell the form to maximize in the property window at start.

In the form load event place:

Dim mydatagrid as New Datagrid
mydatagrid.Location = New System.Drawing.Point(264, 176)
Mydatagrid.Size = New System.Drawing.Size(700, 500)
mydatagrid.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Bottom) _
' Or System.Windows.Forms.AnchorStyles.Left) _
' Or System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)

Mydatagrid.Visible = True

The form will only size to what you declared as size and not anchor to
the sides as it will otherwise.

Any ideas would be helpful.

Nov 21 '05 #4

P: n/a
Kelly,

I miss the code where you add it to the form

Cor
Nov 21 '05 #5

P: n/a
In the form load event place:

Dim mydatagrid as New Datagrid
mydatagrid.Location = New System.Drawing.Point(264, 176)
Mydatagrid.Size = New System.Drawing.Size(700, 500)
mydatagrid.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Bottom) _
' Or System.Windows.Forms.AnchorStyles.Left) _
' Or System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)

Mydatagrid.Visible = True

"Cor Ligthert" <no************@planet.nl> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl:
Kelly,

I miss the code where you add it to the form

Cor


Nov 21 '05 #6

P: n/a
Kelly,

When this is your only code than that datagrid you create will never be on
screen, maybe you have as well somewhere another one.
Dim mydatagrid as New Datagrid
'Probably is this sentence above the guild and could be deleted
mydatagrid.Location = New System.Drawing.Point(264, 176)
Mydatagrid.Size = New System.Drawing.Size(700, 500)
mydatagrid.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Bottom) _
' Or System.Windows.Forms.AnchorStyles.Left) _
' Or System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Mydatagrid.Visible = True
Otherwise there should be something as
me.controls.add(mydatagrid)

I hope this helps?

Cor
"Cor Ligthert" <no************@planet.nl> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl:
Kelly,

I miss the code where you add it to the form

Cor

Nov 21 '05 #7

P: n/a
You are right. You will see the size problem if you add

Me.Controls.Add(mydatagrid)

"Cor Ligthert" <no************@planet.nl> wrote in message
news:uE*************@tk2msftngp13.phx.gbl:
Kelly,

When this is your only code than that datagrid you create will never be on

screen, maybe you have as well somewhere another one.
Dim mydatagrid as New Datagrid


'Probably is this sentence above the guild and could be deleted
mydatagrid.Location = New System.Drawing.Point(264, 176)
Mydatagrid.Size = New System.Drawing.Size(700, 500)
mydatagrid.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Bottom) _
' Or System.Windows.Forms.AnchorStyles.Left) _
' Or System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Mydatagrid.Visible = True


Otherwise there should be something as
me.controls.add(mydatagrid)

I hope this helps?

Cor
"Cor Ligthert" <no************@planet.nl> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl:
Kelly,

I miss the code where you add it to the form

Cor


Nov 21 '05 #8

P: n/a
Kelly,

I have used this code (yours with some new measurements and the form
measurment as well)

\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.Size = New System.Drawing.Size(750, 570)
Dim mydatagrid As New DataGrid
mydatagrid.Location = New System.Drawing.Point(25, 25)
mydatagrid.Size = New System.Drawing.Size(700, 500)
mydatagrid.Anchor = _
CType((((System.Windows.Forms.AnchorStyles.Top _
Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), _
System.Windows.Forms.AnchorStyles)
mydatagrid.Visible = True
Me.Controls.Add(mydatagrid)
End Sub
///

It shows me a nice form with in the middle an empty datagrid, which when I
maximize becomes larger and when I minimize becomes smaller, can you test
this as well?

I hope it helps?

Cor

"scorpion53061" <ad***@nospamherekjmsolutions.com>
....
You are right. You will see the size problem if you add

Me.Controls.Add(mydatagrid)

Nov 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.