Hi,
I am trying to create a form and add some controls to it programmaticall y. I
am pasting the code I have so far, below. here are the issues I am having.
#1. I am having to subtract additional 35 points from the
closeAbuotButto n.Top ot the control goes out of form's bounds. I have no
clue why.
#2. I do not know how to access my Close Button's click event. It is asking
me to create "WithEvents " but I can't figure our where/how to use it.
Thank you.
'Code still not working...
Private Sub aboutHelpMenuIt em_Click(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles aboutHelpMenuIt em.Click
'Create and Display About Dialog.
Dim nameLabel As New Label
Dim messageLabel As New Label
aboutForm = New Form
'Create Form
With aboutForm
.Text = "About"
.FormBorderStyl e = FormBorderStyle .FixedDialog
.Height = 150
.Width = 300
'.ControlBox = False
End With
'Add Message Label
aboutForm.Contr ols.Add(message Label)
With messageLabel
.Text = "Programmed by Me"
.Top = 5
.Left = 5
.Width = aboutForm.Width - 5
.Height = 20
.TextAlign = ContentAlignmen t.MiddleCenter
End With
'Add Close Button
aboutForm.Contr ols.Add(closeAb outButton)
With closeAboutButto n
.Hide()
.Text = "&Close"
.Width = 100
.Height = 25
.Top = aboutForm.Heigh t - closeAboutButto n.Height - 35 'For some reason
if I do not have -35, control goes out of form's bounds.
.Left = (aboutForm.Widt h / 2) - (closeAboutButt on.Width / 2)
.Show()
End With
aboutForm.ShowD ialog()
End Sub
Private Sub closeAboutButto n_Click(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles closeAboutButto n.Click
'Close Form
Me.Close()
End Sub 7 1564
Dragon wrote: Hi,
I am trying to create a form and add some controls to it programmaticall y. I am pasting the code I have so far, below. here are the issues I am having.
#1. I am having to subtract additional 35 points from the closeAbuotButto n.Top ot the control goes out of form's bounds. I have no clue why. #2. I do not know how to access my Close Button's click event. It is asking me to create "WithEvents " but I can't figure our where/how to use it.
Thank you.
'Code still not working... Private Sub aboutHelpMenuIt em_Click(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles aboutHelpMenuIt em.Click 'Create and Display About Dialog.
Dim nameLabel As New Label Dim messageLabel As New Label aboutForm = New Form
'Create Form With aboutForm .Text = "About" .FormBorderStyl e = FormBorderStyle .FixedDialog .Height = 150 .Width = 300 '.ControlBox = False End With
'Add Message Label aboutForm.Contr ols.Add(message Label) With messageLabel .Text = "Programmed by Me" .Top = 5 .Left = 5 .Width = aboutForm.Width - 5 .Height = 20 .TextAlign = ContentAlignmen t.MiddleCenter End With
'Add Close Button aboutForm.Contr ols.Add(closeAb outButton) With closeAboutButto n .Hide() .Text = "&Close" .Width = 100 .Height = 25 .Top = aboutForm.Heigh t - closeAboutButto n.Height - 35 'For some reason if I do not have -35, control goes out of form's bounds. .Left = (aboutForm.Widt h / 2) - (closeAboutButt on.Width / 2) .Show() End With
aboutForm.ShowD ialog()
End Sub
Private Sub closeAboutButto n_Click(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles closeAboutButto n.Click 'Close Form Me.Close() End Sub
You dont' show the code where you create closeAboutButto n, but the
declare needs to look like
dim WithEvents Variable as ObjectType
This gives you to hook into events of the object.
As for why you have to -35 off the top. This is because of the border
and Title bar. If you just want the inside height of the form use this.
..Top = aboutForm.Clien tSize.Height - closeAboutButto n.Height
Hope it helps
Chris
"Dragon" <ba***********@ hotmail.com> schrieb: #2. I do not know how to access my Close Button's click event. It is asking me to create "WithEvents " but I can't figure our where/how to use it.
Take a look at the documentation for the 'AddHandler' statement. You can
use this statement to dynamically add an event handler:
\\\
AddHandler btn.Click, AddressOf Me.Button_Click
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Thank you for your reply.
I have tried dimming the button like:
Dim WithEvents closeAboutButto n As Button
but I get an error saying "WithEvents " is not valid on a local veriable
declaration.
Any ideas?
"Chris" <no@spam.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. Dragon wrote: Hi,
I am trying to create a form and add some controls to it programmaticall y. I am pasting the code I have so far, below. here are the issues I am having.
#1. I am having to subtract additional 35 points from the closeAbuotButto n.Top ot the control goes out of form's bounds. I have no clue why. #2. I do not know how to access my Close Button's click event. It is asking me to create "WithEvents " but I can't figure our where/how to use it.
Thank you.
'Code still not working... Private Sub aboutHelpMenuIt em_Click(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles aboutHelpMenuIt em.Click 'Create and Display About Dialog.
Dim nameLabel As New Label Dim messageLabel As New Label aboutForm = New Form
'Create Form With aboutForm .Text = "About" .FormBorderStyl e = FormBorderStyle .FixedDialog .Height = 150 .Width = 300 '.ControlBox = False End With
'Add Message Label aboutForm.Contr ols.Add(message Label) With messageLabel .Text = "Programmed by Me" .Top = 5 .Left = 5 .Width = aboutForm.Width - 5 .Height = 20 .TextAlign = ContentAlignmen t.MiddleCenter End With
'Add Close Button aboutForm.Contr ols.Add(closeAb outButton) With closeAboutButto n .Hide() .Text = "&Close" .Width = 100 .Height = 25 .Top = aboutForm.Heigh t - closeAboutButto n.Height - 35 'For some reason if I do not have -35, control goes out of form's bounds. .Left = (aboutForm.Widt h / 2) - (closeAboutButt on.Width / 2) .Show() End With
aboutForm.ShowD ialog()
End Sub
Private Sub closeAboutButto n_Click(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles closeAboutButto n.Click 'Close Form Me.Close() End Sub
You dont' show the code where you create closeAboutButto n, but the declare needs to look like
dim WithEvents Variable as ObjectType
This gives you to hook into events of the object.
As for why you have to -35 off the top. This is because of the border and Title bar. If you just want the inside height of the form use this.
.Top = aboutForm.Clien tSize.Height - closeAboutButto n.Height
Hope it helps Chris
Thank you Herfried. I will have to look into this for sure.
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:uJ******** ******@tk2msftn gp13.phx.gbl... "Dragon" <ba***********@ hotmail.com> schrieb: #2. I do not know how to access my Close Button's click event. It is asking me to create "WithEvents " but I can't figure our where/how to use it.
Take a look at the documentation for the 'AddHandler' statement. You can use this statement to dynamically add an event handler:
\\\ AddHandler btn.Click, AddressOf Me.Button_Click ///
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
Dragon wrote: Thank you for your reply.
I have tried dimming the button like:
Dim WithEvents closeAboutButto n As Button
but I get an error saying "WithEvents " is not valid on a local veriable declaration.
Any ideas?
"Chris" <no@spam.com> wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Dragon wrote:
Hi,
I am trying to create a form and add some controls to it programmatic ally. I am pasting the code I have so far, below. here are the issues I am having.
#1. I am having to subtract additional 35 points from the closeAbuotBu tton.Top ot the control goes out of form's bounds. I have no clue why. #2. I do not know how to access my Close Button's click event. It is asking me to create "WithEvents " but I can't figure our where/how to use it.
Thank you.
'Code still not working... Private Sub aboutHelpMenuIt em_Click(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles aboutHelpMenuIt em.Click 'Create and Display About Dialog.
Dim nameLabel As New Label Dim messageLabel As New Label aboutForm = New Form
'Create Form With aboutForm .Text = "About" .FormBorderStyl e = FormBorderStyle .FixedDialog .Height = 150 .Width = 300 '.ControlBox = False End With
'Add Message Label aboutForm.Co ntrols.Add(mess ageLabel) With messageLabel .Text = "Programmed by Me" .Top = 5 .Left = 5 .Width = aboutForm.Width - 5 .Height = 20 .TextAlign = ContentAlignmen t.MiddleCenter End With
'Add Close Button aboutForm.Co ntrols.Add(clos eAboutButton) With closeAboutButto n .Hide() .Text = "&Close" .Width = 100 .Height = 25 .Top = aboutForm.Heigh t - closeAboutButto n.Height - 35 'For some reason if I do not have -35, control goes out of form's bounds. .Left = (aboutForm.Widt h / 2) - (closeAboutButt on.Width / 2) .Show() End With
aboutForm.Sh owDialog()
End Sub
Private Sub closeAboutButto n_Click(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles closeAboutButto n.Click 'Close Form Me.Close() End Sub
You dont' show the code where you create closeAboutButto n, but the declare needs to look like
dim WithEvents Variable as ObjectType
This gives you to hook into events of the object.
As for why you have to -35 off the top. This is because of the border and Title bar. If you just want the inside height of the form use this.
.Top = aboutForm.Clien tSize.Height - closeAboutButto n.Height
Hope it helps Chris
You must declare the button on the form level for it to work, not inside
a sub or function.
Chris
"Dragon" <ba***********@ hotmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. .. I am trying to create a form and add some controls to it programmaticall y.
#1. I am having to subtract additional 35 points from the closeAbuotButto n.Top ot the control goes out of form's bounds.
Form.Height and .Width describe the Form /overall/, including
the borders and menubars.
Try using ClientArea.Heig ht and .Width instead.
#2. I do not know how to access my Close Button's click event. It is asking me to create "WithEvents " but I can't figure our where/how to use it.
As you add each Control, use the AddHandler statement to
"wire up" the Events you're interested in to routines that can process
them, as in ...
Private Sub AnyButton_Click ( sender as Object, e as EventArgs )
. . .
End Sub
.... then ...
x = New Button
AddHandler x.Click, AddressOf AnyButton_Click
HTH,
Phill W.
Thank you Phil.
"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote in message
news:dj******** **@yarrow.open. ac.uk... "Dragon" <ba***********@ hotmail.com> wrote in message news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
I am trying to create a form and add some controls to it programmaticall y.
#1. I am having to subtract additional 35 points from the closeAbuotButto n.Top ot the control goes out of form's bounds.
Form.Height and .Width describe the Form /overall/, including the borders and menubars.
Try using ClientArea.Heig ht and .Width instead.
#2. I do not know how to access my Close Button's click event. It is asking me to create "WithEvents " but I can't figure our where/how to use it.
As you add each Control, use the AddHandler statement to "wire up" the Events you're interested in to routines that can process them, as in ...
Private Sub AnyButton_Click ( sender as Object, e as EventArgs ) . . . End Sub
... then ...
x = New Button AddHandler x.Click, AddressOf AnyButton_Click
HTH, Phill W.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ben |
last post by:
My current project requires me to create part of a form that is
created on the fly. The project consists a list of entries to an
event. The name and address and such is easy. The design is detup so
that the creater of the even can make their own event in the database.
When they do so a 2 tables are created. One for the entries such as
names and the other is for the parameters of each event.
The creator then goes in and makes each event...
|
by: Anand Sagar |
last post by:
I have a Panel1 and button1 on my webform. At runtime, I create 2 textboxes.
I do it at the Page_Load event. I put the code within the " If Not
isPostBack"
For the button click event, I will do a post-to-database coding and then
show the same page again. I put EnableViewState = True for the textboxes.
In the Page_Load if I dont use the IsPostBack checking, the code works fine.
The button shows that the code has been fired and the page...
|
by: Glenn Owens |
last post by:
I have an ASP.Net page on which there are serveral static controls
(listboxes, radiobuttonlist and textboxes). These controls are used to
create criteria from which the code-behind will dynamically create 1-n
datagrids.
When the Submit button is clicked I need to save (in viewstate) the
contents of the criteria controls so that I can recreate the dynamic
DataGrid(s) in the LoadViewState (overloaded method). I need to do
this so that the...
|
by: Patrick |
last post by:
I want to define a set of web-form templates in XML and render the equivalent
web-form with ASP.NET, then process any input server controls on the form.
Reading the XML file from Page_load is easy, but
1) How do I set about dynamically creating user controls (like TextBox,
TextArea)
--- simply Declare and initialised (new) the user controls?? How do I
"place" it graphically on the form. Ideally, I want them to lay out in a
table, one...
|
by: scsharma |
last post by:
Hi,
I am working on creating a webapplication and my design calls for creating
main webform which will have menu bar on left hand side and a IFrame which
will contain all the forms that are shown when menu items are clicked.Besides
these i would like to put a custom status bar. Any error message encountered
in any of the webpage will be displayed in the banner.
The problem iam encountering is how to access the customer status bar in
child...
| |
by: Mats Lycken |
last post by:
Hi,
I'm creating a CMS that I would like to be plug-in based with different
plugins handling different kinds of content.
What I really want is to be able to load/unload plugins on the fly
without restarting the application.
What I did was to create an AppDomain that loaded the plugins and
everything was great, until I tried to pass something else that strings
between the domains...
|
by: bill |
last post by:
I'm using VS2005.
I am dynamically adding a Textbox control to a Placeholder control in the
page_load event of the form, but the event handler isn't firing. What am I
doing wrong?
Thanks
Bill
|
by: Scott McNair |
last post by:
Hi,
I'm creating a user control that has absolutely no visual pieces to it...
it's essentially a piece that sniffs a serial port awaiting incoming data.
I know that there are several controls that come natively with .NET that
don't actually reside on the form, but go to the bottom area, such as for
example database-related controls. How would I go about setting my own
control to do just that? Otherwise I'm left with the quandary of...
|
by: jehugaleahsa |
last post by:
Hello:
We are implementing a work flow system. We would like there to be one
site hosting all the different work flows. Each state in the work flow
is to be associated with a web user control (or something equivalent)
that can be loaded dynamically and displayed. The control will provide
events to allow the host web site to observe user interaction and
eventually transition the work flow to the next state.
We are right now doing some...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |