-
Apr 19th, 2020, 08:42 PM
#1
Thread Starter
Member
Problem with my project
So In my program I’ve putted a flowlayourpanel and with a button I add to the layout infinite new buttons
(button.name = “button” + i.tostring) [i = i + 1]
With another button I want to hide the button with the i=3 so button3.hide(), but it doesn’t work beacause it doesn’t exist yet so How can I refer to the button created when the i was 3?
-
Apr 19th, 2020, 08:54 PM
#2
Re: Problem with my project
Try this...
Code:
Dim x As Integer = 3
Me.FlowLayoutPanel1.Controls("Button" & x.ToString).Hide()
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Apr 19th, 2020, 08:59 PM
#3
Thread Starter
Member
Re: Problem with my project
Originally Posted by .paul.
Try this...
Code:
Dim x As Integer = 3
Me.FlowLayoutPanel1.Controls("Button" & x.ToString).Hide()
Thanks I will try it tomorrow and let u know
-
Apr 19th, 2020, 09:16 PM
#4
Re: Problem with my project
Originally Posted by .paul.
Try this...
Code:
Dim x As Integer = 3
Me.FlowLayoutPanel1.Controls("Button" & x.ToString).Hide()
Just a small thing for the record: you don't need the ToString in that case. It's not wrong and may be considered to add clarity but the concatenation operator always widens its operands to type String so any and every time it is used to already know that both operands will be converted to a String if they can be. Any operands that cannot be widened to type String cannot be used with the concatenation operator and would require an explicit conversion.
-
Apr 20th, 2020, 07:08 AM
#5
Thread Starter
Member
Re: Problem with my project
Originally Posted by .paul.
Try this...
Code:
Dim x As Integer = 3
Me.FlowLayoutPanel1.Controls("Button" & x.ToString).Hide()
Perfect it did work
One more thing: I set x = senderX.name that is the button witch I click to hide the other one and all works
I click button “1” and the “button1” hides I click button “2” and the “button2” hides but now I want that when I hide the (“button” & x.toSting) x= 2 I want that all the other buttons shows.
How can I do this?
I thought like me.flowlayoutpanel.controls( control.name.contains “button”).show exept me.flowlayoutpanel.controls(“button” & x.tostring) X=SenderX
-
Apr 20th, 2020, 07:26 AM
#6
Re: Problem with my project
Code:
For each b as Button in FlowLayoutPanel1.Controls.OfType(of Button)
b.Visible = True
Next
‘ now All buttons are visible hide your selected button here
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Apr 20th, 2020, 08:38 AM
#7
Thread Starter
Member
Re: Problem with my project
Originally Posted by .paul.
Code:
For each b as Button in FlowLayoutPanel1.Controls.OfType(of Button)
b.Visible = True
Next
‘ now All buttons are visible hide your selected button here
thank u very mutch
-
Apr 20th, 2020, 08:38 AM
#8
Thread Starter
Member
Re: Problem with my project
Originally Posted by .paul.
Code:
For each b as Button in FlowLayoutPanel1.Controls.OfType(of Button)
b.Visible = True
Next
‘ now All buttons are visible hide your selected button here
thank u very mutch
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|