Library tutorials & articles
Windows Forms and Controls
The Complete Form Class
By now you will have noticed that the code behind the form contains a lot more
than just the button events we accessed. In fact it contains everything needed
to create what we created using the visual designer. We could have opened notepad,
and typed all of it in ourselves, then compiled it and it would have executed
just fine. In fact lets do just that but let’s not type it in. We can copy and
paste what we need. We don’t need some of the designer specific code created
by VS.Net so to be clear here’s what we’ll use:-
First off we need to create our references and declare the form Class
Imports System
Imports System.Windows.Forms
Imports System.Drawing
Public Class frmMain
Inherits System.Windows.Forms.Form
This declares the form and specifies that it Inherits from the form namespace,
i.e. it is a form.
Next up we declare our controls outside of the following procedures
Friend WithEvents cbCancel As System.Windows.Forms.Button
Friend WithEvents cbAccept As System.Windows.Forms.Button
Friend WithEvents txtEnteredText As System.Windows.Forms.TextBox
Friend WithEvents lblEnterText As System.Windows.Forms.Label
The Friend keyword allows us access to them from the second instance of the form
we create. You can use Private if you don’t want to directly access them from
inherited forms.
Shared Sub Main()
System.Windows.Forms.Application.Run(New frmMain())
End Sub
This is the Main procedure that the compiler looks for in any project.It’s the
first thing that runs when you launch the exe.
Related articles
Related discussion
-
How to write the category attribut in a class dynamically
by converter2009 (1 replies)
-
VB.NET: Hide and show table using radio buttons
by converter2009 (1 replies)
-
VB.Net Button Problem
by pysdex (0 replies)
-
Unable to access AxInterop.AcoPdflib.dll on 64 bit OS
by Shaila14041981 (0 replies)
-
Very Urgent regarding deleting the images from a folder
by Nanosteps (6 replies)
Related podcasts
-
xpert to Expert: Inside Concurrent Basic (CB)
"Concurrent Basic extends Visual Basic with stylish asynchronous concurrency constructs derived from the join calculus. Our design advances earlier MSRC work on Polyphonic C#, Comega and the Joins Library. Unlike its C# based predecessors, CB adopts a simple event-like syntax familiar to VB progr...
Only 5 years after the last post eh :) Anyway because things may have changed I recommend you look at the microsoft docs on this - http://msdn.microsoft.com/en-us/library/ms229597(VS.80).aspx
It may not work with mdi children.
I use VB.Net (framework 1.0.3705) on Windows 2000, and I noticed the 'MinimumSize' property doesn't seem to have any effect on my forms (MDIChildren). Does that property really prevent users from resizing a form to a smaller size than the MinimumSize? Any other experiences?
Thank you,
This thread is for discussions of Windows Forms and Controls.