473,728 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A question regarding the Name property

Rob
I am reading a book that says that the "name" property can be altered only
at design time and cannot be modified at runtime.

Please explain this given the code below...

If you click Button3... fred will appear as the Name of Button1, however,
the handler for Button1 works still works as well...
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
MsgBox("HELP")

End Sub

Private Sub Button3_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button3.Click
Me.Button1.Name = "fred"
Dim i As Integer = 0
Dim str As String

While i < Me.Controls.Cou nt
Dim c As Control = Me.Controls(i)
str = c.Name
MsgBox(str)
i = i + 1

End While
End Sub

May 13 '07 #1
10 1506
Rob,

I am afraid that I don't understand your question complete, but ever control
has a collection of controls. (So that one has that again). That collection
has nothing to do with indiviuel names of collection items.

Cor
"Rob" <ro***@yahoo.co mschreef in bericht
news:HY******** *************** *******@comcast .com...
>I am reading a book that says that the "name" property can be altered only
at design time and cannot be modified at runtime.

Please explain this given the code below...

If you click Button3... fred will appear as the Name of Button1, however,
the handler for Button1 works still works as well...
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
MsgBox("HELP")

End Sub

Private Sub Button3_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button3.Click
Me.Button1.Name = "fred"
Dim i As Integer = 0
Dim str As String

While i < Me.Controls.Cou nt
Dim c As Control = Me.Controls(i)
str = c.Name
MsgBox(str)
i = i + 1

End While
End Sub

May 14 '07 #2
On May 13, 6:56 pm, "Rob" <r...@yahoo.com wrote:
I am reading a book that says that the "name" property can be altered only
at design time and cannot be modified at runtime.

Please explain this given the code below...

If you click Button3... fred will appear as the Name of Button1, however,
the handler for Button1 works still works as well...

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
MsgBox("HELP")

End Sub

Private Sub Button3_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button3.Click
Me.Button1.Name = "fred"
Dim i As Integer = 0
Dim str As String

While i < Me.Controls.Cou nt
Dim c As Control = Me.Controls(i)
str = c.Name
MsgBox(str)
i = i + 1

End While
End Sub
I am reading a book that says that the "name" property can be altered only
at design time and cannot be modified at runtime.
What book is this? I would like to have a conversation with the author
as you can change control names at runtime with no problems.
the handler for Button1 works still works as well...
This is because it's handling the Click event for the control Button1,
not the control named "Button1." If you look at the designer generated
code, you will see that when you add a button to the designer it
generates something like this:

Private Sub InitializeCompo nent()
Me.Button1 = New System.Windows. Forms.Button

'
'Button1
'
Me.Button1.Loca tion = New System.Drawing. Point(65, 63)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing. Size(75, 23)
Me.Button1.TabI ndex = 0
Me.Button1.Text = "Button1"
Me.Button1.UseV isualStyleBackC olor = True
End Sub

Friend WithEvents Button1 As System.Windows. Forms.Button

This declares a button, and then in the InitialiazeComp onent method it
sets it's properties - including Name. And since this method should
run whenever a form is instantiated, this proves that runtime
assigning of the Name property is perfectly fine.

Thanks,

Seth Rowe

May 14 '07 #3
Rob
Hi Cor,

Well, the book states that you cannot alter the "name" property of a control
at runtime...

Isn't the clicking of a Button considered "run-time" ?

If so, look at the code for Button3... It changes the name of Button1 to
"fred", then reports that the "name" of Button1 is "fred".

However, the code for Button1 still executes (Handles Button1.click). .. if
the name were really changed to fred, then it should not execute.

Just a little confused...

Thanks,
Rob

"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:ud******** ******@TK2MSFTN GP05.phx.gbl...
Rob,

I am afraid that I don't understand your question complete, but ever
control has a collection of controls. (So that one has that again). That
collection has nothing to do with indiviuel names of collection items.

Cor
"Rob" <ro***@yahoo.co mschreef in bericht
news:HY******** *************** *******@comcast .com...
>>I am reading a book that says that the "name" property can be altered only
at design time and cannot be modified at runtime.

Please explain this given the code below...

If you click Button3... fred will appear as the Name of Button1, however,
the handler for Button1 works still works as well...
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventAr gs) Handles Button1.Click
MsgBox("HELP")

End Sub

Private Sub Button3_Click(B yVal sender As System.Object, ByVal e As
System.EventAr gs) Handles Button3.Click
Me.Button1.Name = "fred"
Dim i As Integer = 0
Dim str As String

While i < Me.Controls.Cou nt
Dim c As Control = Me.Controls(i)
str = c.Name
MsgBox(str)
i = i + 1

End While
End Sub


May 14 '07 #4
Rob
Seth,

I want to make sure I have stated correctly and in the proper context...

From the book...

Regarding common properties of controls (to quote)...

Name - "Represents the name used to refer to the control in code. This
property can be altered only at design time and cannot be modified at run
time."

So I guess the control has some "unique attribute" other than the "name"
property that uniquely identifies it. Maybe that is the attribute that
cannot be changed ?

Anyway, I created 2 buttons on a form (used VS2003 for this), then modified
the code as follows... I expected it to crash due to the duplicate Button1
instantiation, instead, it appeared to apply a "last line of code wins"
logic set... as the sole button that appeared had its text property set to
"Button2".
Me.Button1 = New System.Windows. Forms.Button
' Formerly Button 2 below
Me.Button1 = New System.Windows. Forms.Button
Me.SuspendLayou t()
'
'Button1
'
Me.Button1.Loca tion = New System.Drawing. Point(88, 8)
Me.Button1.Name = "Button1"
Me.Button1.TabI ndex = 0
Me.Button1.Text = "Button1"
'
'Button2
' Changed the following....
Me.Button1.Loca tion = New System.Drawing. Point(80, 56)
Me.Button1.Name = "Button1"
Me.Button1.TabI ndex = 1
Me.Button1.Text = "Button2"

Thanks,
Rob

"rowe_newsgroup s" <ro********@yah oo.comwrote in message
news:11******** *************@w 5g2000hsg.googl egroups.com...
On May 13, 6:56 pm, "Rob" <r...@yahoo.com wrote:
>I am reading a book that says that the "name" property can be altered
only
at design time and cannot be modified at runtime.

Please explain this given the code below...

If you click Button3... fred will appear as the Name of Button1, however,
the handler for Button1 works still works as well...

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventAr gs) Handles Button1.Click
MsgBox("HELP")

End Sub

Private Sub Button3_Click(B yVal sender As System.Object, ByVal e As
System.EventAr gs) Handles Button3.Click
Me.Button1.Name = "fred"
Dim i As Integer = 0
Dim str As String

While i < Me.Controls.Cou nt
Dim c As Control = Me.Controls(i)
str = c.Name
MsgBox(str)
i = i + 1

End While
End Sub

>I am reading a book that says that the "name" property can be altered
only
at design time and cannot be modified at runtime.

What book is this? I would like to have a conversation with the author
as you can change control names at runtime with no problems.
>the handler for Button1 works still works as well...

This is because it's handling the Click event for the control Button1,
not the control named "Button1." If you look at the designer generated
code, you will see that when you add a button to the designer it
generates something like this:

Private Sub InitializeCompo nent()
Me.Button1 = New System.Windows. Forms.Button

'
'Button1
'
Me.Button1.Loca tion = New System.Drawing. Point(65, 63)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing. Size(75, 23)
Me.Button1.TabI ndex = 0
Me.Button1.Text = "Button1"
Me.Button1.UseV isualStyleBackC olor = True
End Sub

Friend WithEvents Button1 As System.Windows. Forms.Button

This declares a button, and then in the InitialiazeComp onent method it
sets it's properties - including Name. And since this method should
run whenever a form is instantiated, this proves that runtime
assigning of the Name property is perfectly fine.

Thanks,

Seth Rowe

May 14 '07 #5
On May 14, 8:22 am, "Rob" <r...@yahoo.com wrote:
Seth,

I want to make sure I have stated correctly and in the proper context...

From the book...

Regarding common properties of controls (to quote)...

Name - "Represents the name used to refer to the control in code. This
property can be altered only at design time and cannot be modified at run
time."

So I guess the control has some "unique attribute" other than the "name"
property that uniquely identifies it. Maybe that is the attribute that
cannot be changed ?

Anyway, I created 2 buttons on a form (used VS2003 for this), then modified
the code as follows... I expected it to crash due to the duplicate Button1
instantiation, instead, it appeared to apply a "last line of code wins"
logic set... as the sole button that appeared had its text property set to
"Button2".

Me.Button1 = New System.Windows. Forms.Button
' Formerly Button 2 below
Me.Button1 = New System.Windows. Forms.Button
Me.SuspendLayou t()
'
'Button1
'
Me.Button1.Loca tion = New System.Drawing. Point(88, 8)
Me.Button1.Name = "Button1"
Me.Button1.TabI ndex = 0
Me.Button1.Text = "Button1"
'
'Button2
' Changed the following....
Me.Button1.Loca tion = New System.Drawing. Point(80, 56)
Me.Button1.Name = "Button1"
Me.Button1.TabI ndex = 1
Me.Button1.Text = "Button2"

Thanks,
Rob

"rowe_newsgroup s" <rowe_em...@yah oo.comwrote in message

news:11******** *************@w 5g2000hsg.googl egroups.com...
On May 13, 6:56 pm, "Rob" <r...@yahoo.com wrote:
I am reading a book that says that the "name" property can be altered
only
at design time and cannot be modified at runtime.
Please explain this given the code below...
If you click Button3... fred will appear as the Name of Button1, however,
the handler for Button1 works still works as well...
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
MsgBox("HELP")
End Sub
Private Sub Button3_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button3.Click
Me.Button1.Name = "fred"
Dim i As Integer = 0
Dim str As String
While i < Me.Controls.Cou nt
Dim c As Control = Me.Controls(i)
str = c.Name
MsgBox(str)
i = i + 1
End While
End Sub
I am reading a book that says that the "name" property can be altered
only
at design time and cannot be modified at runtime.
What book is this? I would like to have a conversation with the author
as you can change control names at runtime with no problems.
the handler for Button1 works still works as well...
This is because it's handling the Click event for the control Button1,
not the control named "Button1." If you look at the designer generated
code, you will see that when you add a button to the designer it
generates something like this:
Private Sub InitializeCompo nent()
Me.Button1 = New System.Windows. Forms.Button
'
'Button1
'
Me.Button1.Loca tion = New System.Drawing. Point(65, 63)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing. Size(75, 23)
Me.Button1.TabI ndex = 0
Me.Button1.Text = "Button1"
Me.Button1.UseV isualStyleBackC olor = True
End Sub
Friend WithEvents Button1 As System.Windows. Forms.Button
This declares a button, and then in the InitialiazeComp onent method it
sets it's properties - including Name. And since this method should
run whenever a form is instantiated, this proves that runtime
assigning of the Name property is perfectly fine.
Thanks,
Seth Rowe
Again, what book are you reading? I'm starting to think you are
reading a VB6 book - not one for Visual Basic .Net.

Thanks,

Seth Rowe

May 14 '07 #6
On May 14, 7:41 am, "Rob" <r...@yahoo.com wrote:
Hi Cor,

Well, the book states that you cannot alter the "name" property of a control
at runtime...

Isn't the clicking of a Button considered "run-time" ?

If so, look at the code for Button3... It changes the name of Button1 to
"fred", then reports that the "name" of Button1 is "fred".

However, the code for Button1 still executes (Handles Button1.click). .. if
the name were really changed to fred, then it should not execute.

Just a little confused...

Thanks,
Rob

"Cor Ligthert [MVP]" <notmyfirstn... @planet.nlwrote in messagenews:ud* *************@T K2MSFTNGP05.phx .gbl...
Rob,
I am afraid that I don't understand your question complete, but ever
control has a collection of controls. (So that one has that again). That
collection has nothing to do with indiviuel names of collection items.
Cor
"Rob" <r...@yahoo.com schreef in bericht
news:HY******** *************** *******@comcast .com...
>I am reading a book that says that the "name" property can be altered only
at design time and cannot be modified at runtime.
Please explain this given the code below...
If you click Button3... fred will appear as the Name of Button1, however,
the handler for Button1 works still works as well...
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
MsgBox("HELP")
End Sub
Private Sub Button3_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button3.Click
Me.Button1.Name = "fred"
Dim i As Integer = 0
Dim str As String
While i < Me.Controls.Cou nt
Dim c As Control = Me.Controls(i)
str = c.Name
MsgBox(str)
i = i + 1
End While
End Sub
However, the code for Button1 still executes (Handles Button1.click). .. if
the name were really changed to fred, then it should not execute.
Read my earlier post. The handles clause refers to the object, not the
object's name.

Thanks,

Seth Rowe

May 14 '07 #7
Rob
Microsoft .Net Framework 2.0 Windows-based Client Development
Self paced Training kit for Exam 70-526
Page 53

Thanks,
Rob

"rowe_newsgroup s" <ro********@yah oo.comwrote in message
news:11******** **************@ w5g2000hsg.goog legroups.com...
On May 14, 8:22 am, "Rob" <r...@yahoo.com wrote:
>Seth,

I want to make sure I have stated correctly and in the proper context...

From the book...

Regarding common properties of controls (to quote)...

Name - "Represents the name used to refer to the control in code. This
property can be altered only at design time and cannot be modified at run
time."

So I guess the control has some "unique attribute" other than the "name"
property that uniquely identifies it. Maybe that is the attribute that
cannot be changed ?

Anyway, I created 2 buttons on a form (used VS2003 for this), then
modified
the code as follows... I expected it to crash due to the duplicate
Button1
instantiatio n, instead, it appeared to apply a "last line of code wins"
logic set... as the sole button that appeared had its text property set
to
"Button2".

Me.Button1 = New System.Windows. Forms.Button
' Formerly Button 2 below
Me.Button1 = New System.Windows. Forms.Button
Me.SuspendLayou t()
'
'Button1
'
Me.Button1.Loca tion = New System.Drawing. Point(88, 8)
Me.Button1.Name = "Button1"
Me.Button1.TabI ndex = 0
Me.Button1.Text = "Button1"
'
'Button2
' Changed the following....
Me.Button1.Loca tion = New System.Drawing. Point(80, 56)
Me.Button1.Name = "Button1"
Me.Button1.TabI ndex = 1
Me.Button1.Text = "Button2"

Thanks,
Rob

"rowe_newsgrou ps" <rowe_em...@yah oo.comwrote in message

news:11******* **************@ w5g2000hsg.goog legroups.com...
On May 13, 6:56 pm, "Rob" <r...@yahoo.com wrote:
I am reading a book that says that the "name" property can be altered
only
at design time and cannot be modified at runtime.
>Please explain this given the code below...
>If you click Button3... fred will appear as the Name of Button1,
however,
the handler for Button1 works still works as well...
> Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As
System.EventAr gs) Handles Button1.Click
MsgBox("HELP")
> End Sub
> Private Sub Button3_Click(B yVal sender As System.Object, ByVal e
As
System.EventAr gs) Handles Button3.Click
Me.Button1.Name = "fred"
Dim i As Integer = 0
Dim str As String
> While i < Me.Controls.Cou nt
Dim c As Control = Me.Controls(i)
str = c.Name
MsgBox(str)
i = i + 1
> End While
End Sub
>I am reading a book that says that the "name" property can be altered
only
at design time and cannot be modified at runtime.
What book is this? I would like to have a conversation with the author
as you can change control names at runtime with no problems.
>the handler for Button1 works still works as well...
This is because it's handling the Click event for the control Button1,
not the control named "Button1." If you look at the designer generated
code, you will see that when you add a button to the designer it
generates something like this:
Private Sub InitializeCompo nent()
Me.Button1 = New System.Windows. Forms.Button
'
'Button1
'
Me.Button1.Loca tion = New System.Drawing. Point(65, 63)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing. Size(75, 23)
Me.Button1.TabI ndex = 0
Me.Button1.Text = "Button1"
Me.Button1.UseV isualStyleBackC olor = True
End Sub
Friend WithEvents Button1 As System.Windows. Forms.Button
This declares a button, and then in the InitialiazeComp onent method it
sets it's properties - including Name. And since this method should
run whenever a form is instantiated, this proves that runtime
assigning of the Name property is perfectly fine.
Thanks,
Seth Rowe

Again, what book are you reading? I'm starting to think you are
reading a VB6 book - not one for Visual Basic .Net.

Thanks,

Seth Rowe

May 14 '07 #8
Rob
As far as a unique control identifier...

I understand what you are saying....

' The following does invoke an error...
Friend WithEvents Button1 As System.Windows. Forms.Button
Friend WithEvents Button1 As System.Windows. Forms.Button


"rowe_newsgroup s" <ro********@yah oo.comwrote in message
news:11******** **************@ w5g2000hsg.goog legroups.com...
On May 14, 8:22 am, "Rob" <r...@yahoo.com wrote:
>Seth,

I want to make sure I have stated correctly and in the proper context...

From the book...

Regarding common properties of controls (to quote)...

Name - "Represents the name used to refer to the control in code. This
property can be altered only at design time and cannot be modified at run
time."

So I guess the control has some "unique attribute" other than the "name"
property that uniquely identifies it. Maybe that is the attribute that
cannot be changed ?

Anyway, I created 2 buttons on a form (used VS2003 for this), then
modified
the code as follows... I expected it to crash due to the duplicate
Button1
instantiatio n, instead, it appeared to apply a "last line of code wins"
logic set... as the sole button that appeared had its text property set
to
"Button2".

Me.Button1 = New System.Windows. Forms.Button
' Formerly Button 2 below
Me.Button1 = New System.Windows. Forms.Button
Me.SuspendLayou t()
'
'Button1
'
Me.Button1.Loca tion = New System.Drawing. Point(88, 8)
Me.Button1.Name = "Button1"
Me.Button1.TabI ndex = 0
Me.Button1.Text = "Button1"
'
'Button2
' Changed the following....
Me.Button1.Loca tion = New System.Drawing. Point(80, 56)
Me.Button1.Name = "Button1"
Me.Button1.TabI ndex = 1
Me.Button1.Text = "Button2"

Thanks,
Rob

"rowe_newsgrou ps" <rowe_em...@yah oo.comwrote in message

news:11******* **************@ w5g2000hsg.goog legroups.com...
On May 13, 6:56 pm, "Rob" <r...@yahoo.com wrote:
I am reading a book that says that the "name" property can be altered
only
at design time and cannot be modified at runtime.
>Please explain this given the code below...
>If you click Button3... fred will appear as the Name of Button1,
however,
the handler for Button1 works still works as well...
> Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As
System.EventAr gs) Handles Button1.Click
MsgBox("HELP")
> End Sub
> Private Sub Button3_Click(B yVal sender As System.Object, ByVal e
As
System.EventAr gs) Handles Button3.Click
Me.Button1.Name = "fred"
Dim i As Integer = 0
Dim str As String
> While i < Me.Controls.Cou nt
Dim c As Control = Me.Controls(i)
str = c.Name
MsgBox(str)
i = i + 1
> End While
End Sub
>I am reading a book that says that the "name" property can be altered
only
at design time and cannot be modified at runtime.
What book is this? I would like to have a conversation with the author
as you can change control names at runtime with no problems.
>the handler for Button1 works still works as well...
This is because it's handling the Click event for the control Button1,
not the control named "Button1." If you look at the designer generated
code, you will see that when you add a button to the designer it
generates something like this:
Private Sub InitializeCompo nent()
Me.Button1 = New System.Windows. Forms.Button
'
'Button1
'
Me.Button1.Loca tion = New System.Drawing. Point(65, 63)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing. Size(75, 23)
Me.Button1.TabI ndex = 0
Me.Button1.Text = "Button1"
Me.Button1.UseV isualStyleBackC olor = True
End Sub
Friend WithEvents Button1 As System.Windows. Forms.Button
This declares a button, and then in the InitialiazeComp onent method it
sets it's properties - including Name. And since this method should
run whenever a form is instantiated, this proves that runtime
assigning of the Name property is perfectly fine.
Thanks,
Seth Rowe

Again, what book are you reading? I'm starting to think you are
reading a VB6 book - not one for Visual Basic .Net.

Thanks,

Seth Rowe

May 14 '07 #9
On May 14, 9:36 am, "Rob" <r...@yahoo.com wrote:
As far as a unique control identifier...

I understand what you are saying....

' The following does invoke an error...
Friend WithEvents Button1 As System.Windows. Forms.Button
Friend WithEvents Button1 As System.Windows. Forms.Button

"rowe_newsgroup s" <rowe_em...@yah oo.comwrote in message

news:11******** **************@ w5g2000hsg.goog legroups.com...
On May 14, 8:22 am, "Rob" <r...@yahoo.com wrote:
Seth,
I want to make sure I have stated correctly and in the proper context...
From the book...
Regarding common properties of controls (to quote)...
Name - "Represents the name used to refer to the control in code. This
property can be altered only at design time and cannot be modified at run
time."
So I guess the control has some "unique attribute" other than the "name"
property that uniquely identifies it. Maybe that is the attribute that
cannot be changed ?
Anyway, I created 2 buttons on a form (used VS2003 for this), then
modified
the code as follows... I expected it to crash due to the duplicate
Button1
instantiation, instead, it appeared to apply a "last line of code wins"
logic set... as the sole button that appeared had its text property set
to
"Button2".
Me.Button1 = New System.Windows. Forms.Button
' Formerly Button 2 below
Me.Button1 = New System.Windows. Forms.Button
Me.SuspendLayou t()
'
'Button1
'
Me.Button1.Loca tion = New System.Drawing. Point(88, 8)
Me.Button1.Name = "Button1"
Me.Button1.TabI ndex = 0
Me.Button1.Text = "Button1"
'
'Button2
' Changed the following....
Me.Button1.Loca tion = New System.Drawing. Point(80, 56)
Me.Button1.Name = "Button1"
Me.Button1.TabI ndex = 1
Me.Button1.Text = "Button2"
Thanks,
Rob
"rowe_newsgroup s" <rowe_em...@yah oo.comwrote in message
>news:11******* **************@ w5g2000hsg.goog legroups.com...
On May 13, 6:56 pm, "Rob" <r...@yahoo.com wrote:
I am reading a book that says that the "name" property can be altered
only
at design time and cannot be modified at runtime.
Please explain this given the code below...
If you click Button3... fred will appear as the Name of Button1,
however,
the handler for Button1 works still works as well...
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As
System.EventArg s) Handles Button1.Click
MsgBox("HELP")
End Sub
Private Sub Button3_Click(B yVal sender As System.Object, ByVal e
As
System.EventArg s) Handles Button3.Click
Me.Button1.Name = "fred"
Dim i As Integer = 0
Dim str As String
While i < Me.Controls.Cou nt
Dim c As Control = Me.Controls(i)
str = c.Name
MsgBox(str)
i = i + 1
End While
End Sub
I am reading a book that says that the "name" property can be altered
only
at design time and cannot be modified at runtime.
What book is this? I would like to have a conversation with the author
as you can change control names at runtime with no problems.
the handler for Button1 works still works as well...
This is because it's handling the Click event for the control Button1,
not the control named "Button1." If you look at the designer generated
code, you will see that when you add a button to the designer it
generates something like this:
Private Sub InitializeCompo nent()
Me.Button1 = New System.Windows. Forms.Button
'
'Button1
'
Me.Button1.Loca tion = New System.Drawing. Point(65, 63)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing. Size(75, 23)
Me.Button1.TabI ndex = 0
Me.Button1.Text = "Button1"
Me.Button1.UseV isualStyleBackC olor = True
End Sub
Friend WithEvents Button1 As System.Windows. Forms.Button
This declares a button, and then in the InitialiazeComp onent method it
sets it's properties - including Name. And since this method should
run whenever a form is instantiated, this proves that runtime
assigning of the Name property is perfectly fine.
Thanks,
Seth Rowe
Again, what book are you reading? I'm starting to think you are
reading a VB6 book - not one for Visual Basic .Net.
Thanks,
Seth Rowe
As far as a unique control identifier...

I understand what you are saying....
Good! The only time I use the Name property is when I am using the
FindControl method on dynamically created controls.

Thanks,

Seth Rowe

May 14 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2991
by: Marcelo | last post by:
Hello, I am trying to create a postback event, and it is working, just not calling the sub. I have a datagrid which has <asp:DataGrid id="Mensajes" ... <Columns> <asp:HyperLinkColumn ....
2
1897
by: Wysiwyg | last post by:
I was hoping to get some opinions on the efficiency of various methods of reusing the same dropdown list data. Here is the situation: Multiple panels on maintenance pages with TAB menus across the top showing different panels. A DropDownList with a 50+ value/text entries exists on more than one panel but only one will be displayed at a time. Examples might be US states, countries, category codes, etc.
1
1314
by: Terrance | last post by:
Hello, I was wondering if someone can help me understand something. Below is some code that I got from the MS website that is suppose to authenticate for the username and password on the local machine. I tested this code in VB.net 2003 in a WINDOW FORM class and it seems to work fine. However, when I test it in VB.net 2005 Express Edition it works for the login portion but it doesn't display the error message if the user name and password...
11
3489
by: Alexander Walker | last post by:
Hello I would like to write a method that allows me to pass a reference to an instance of a class, the name of a property of that class and a value to set that property to, the method would then set the property of the instance to the value here is an example of what the method might look like public void SetProperty(object instance, string property, object value) {
5
2407
by: archana | last post by:
Hi all, I am having confusion regarding localization in .net. I have one form on which i have some labels and button. After designing that form what i did is set localization property of form to true and i set language as french. But still it is not changing caption of controls which are there in form.
8
2253
by: Roger | last post by:
I have a question regarding the behaviour of sql with OR and fetch first 1 rows only : I have a table with data : ACNO NAME TELNO CITY ZIP 1000 tim 8887778888 denver 1000 tim 8887778888 denver 56465
6
2451
by: Mikus Sleiners | last post by:
Is there any way to enable exception throws in VS 2005, that occur during binding operations? I am upset that i can't see exceptions that are thrown during binding operations. It's very hard to track down erroneous behaviour of your app if you can't see where the problem is... i mean it's realy hard to debug binding issues and it would be realy of help if i could somehow enable this during debug session.
3
3964
by: Michel Esber | last post by:
Hi all, DB2 V8 LUW FP 15 There is a table T (ID varchar (24), ABC timestamp). ID is PK. Our application needs to frequently update T with a new value for ABC. update T set ABC=? where ID = ?
1
1440
by: =?Utf-8?B?U3VtaXQgUmF3YXQgSW5kaWE=?= | last post by:
What I have seen in Asp.net applications that if i put two Asp buttons on the web form(Aspx page) it generates multiple name attribute of input tag on the client side. for eg. <asp:Button ID="btn" value="first" runat="server" name="btnname"/> <asp:Button ID="Button1" value="second" runat="server" name="btnname"/> After the execution it shows the result in following way:--
0
8756
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,...
0
9416
Oralloy
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...
0
9270
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 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...
1
9194
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8123
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6711
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 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...
0
6012
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2649
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2159
bsmnconsultancy
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...

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.