473,412 Members | 2,994 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Datagrid, Anchor and Form Load

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
8 4939
"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
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
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
Kelly,

I miss the code where you add it to the form

Cor
Nov 21 '05 #5
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Chris Thunell | last post by:
Right now I have a vb.net windows form project that does a whole bunch of things on the form.load event. The problem with this is that the user does not see the form until all the those things are...
0
by: Giri | last post by:
Hi there..You cannot close a form in Load. You can set a flag and close it in Activate Event of Form Warm regards, Giri >-----Original Message----- >I need to be able to close the form (or...
1
by: B | last post by:
Hi, I would like to split up an mdi form using a splitter where a datagrid would be on the left side and child forms on the right side. So far, I have placed a splitter on the form, dragged it...
3
by: Dennis | last post by:
I have the following code for showing a form: dim frm as new myForm frm.ShowDialog (The Form Load Event is fired then I hide the form using Me.Hide when the X in the UR corner is clicked). ...
2
by: lgbjr | last post by:
Hi All, I see that this topic was discussed back on august 23rd, but I didn't see a real answer. I have a VB.NET MDI app. A particular menu action on the MDI parent is to call an OpenFileDialog...
1
by: Jason Richmeier | last post by:
I am experiencing some unexpected behavior with the Form Load event in a Windows application. Hopefully, someone can explain why this behavior is occurring. In my application, I have a form...
6
by: tony | last post by:
Hello! When exactly is it important or advisable to use this form load event handler compare to using the C-tor. For example here I create an event handler called dataBoundGridForm that is...
3
by: jamesnkk | last post by:
Hi, I am new to vb6. I have some code written in the form load. the first time when I call the form, the code inside form load will activate. After I have complete the form and return to main...
4
by: rb0135 | last post by:
Hi, I am writing a C# mobile 6 (dot.net 3.5) application. On the form, I have a label. I update this label with text as my initalizing routines are running (from the form load event), such as...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.