473,397 Members | 1,972 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,397 software developers and data experts.

how to remove a button?

Hello,

I have a button which the user clicks to move to the next question and
when the last question is answered I would like the button to be
removed. How do I do this?

Thanks

Geoff
Nov 17 '05 #1
4 2389
Geoff,

You can call the Remove or RemoveAt methods on the Controls collection
that is exposed by the parent control/form. You can also set the Visible
property on the control to false, but this will not remove the instance of
the control, it will just hide the control (you might want to bring it back
if you are navigating back and forth).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<Geoff Cox> wrote in message
news:6l********************************@4ax.com...
Hello,

I have a button which the user clicks to move to the next question and
when the last question is answered I would like the button to be
removed. How do I do this?

Thanks

Geoff

Nov 17 '05 #2
On Wed, 10 Aug 2005 11:26:19 -0400, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote:
Geoff,

You can call the Remove or RemoveAt methods on the Controls collection
that is exposed by the parent control/form. You can also set the Visible
property on the control to false, but this will not remove the instance of
the control, it will just hide the control (you might want to bring it back
if you are navigating back and forth).
Nicholas,

Thanks! The "make invisible" works fine - wonder if you might help
with this - I want ot be able to add the various TrackBar values to
the data.txt file until there are no more questions to answer ... not
sure how to keep the file open.

I would like to close the file after

this.button1.Visible = false;

but not sure how to refer to the tw.Close()

Geoff.

private void button1_MouseClick(object sender, MouseEventArgs e)
{
TextWriter tw = new StreamWriter("d:\\a-temp1\\data.txt");
tw.WriteLine(trackBar1.Value);
tw.Close();

++qnumber;

if (qnumber == LHSquestions.Length)
{
endMessage();
}
else
{

this.label1.Text = LHSquestions[qnumber];
this.label2.Text = RHSquestions[qnumber];

}
}

private void endMessage()
{
this.label1.Text = "Finished!";
this.label2.Text = "Thank you";
this.button1.Visible = false;
}



Hope this helps.


Nov 17 '05 #3
Geoff,

I wouldn't bother writing the values as they are selected (it would be a
pain to "erase" them from your text file if you navigated back and forth).

Rather, I would wait until you have all the values (store them in
memory), and then write them to the file once when the operation is
complete.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<Geoff Cox> wrote in message
news:3b********************************@4ax.com...
On Wed, 10 Aug 2005 11:26:19 -0400, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote:
Geoff,

You can call the Remove or RemoveAt methods on the Controls collection
that is exposed by the parent control/form. You can also set the Visible
property on the control to false, but this will not remove the instance of
the control, it will just hide the control (you might want to bring it
back
if you are navigating back and forth).


Nicholas,

Thanks! The "make invisible" works fine - wonder if you might help
with this - I want ot be able to add the various TrackBar values to
the data.txt file until there are no more questions to answer ... not
sure how to keep the file open.

I would like to close the file after

this.button1.Visible = false;

but not sure how to refer to the tw.Close()

Geoff.

private void button1_MouseClick(object sender, MouseEventArgs e)
{
TextWriter tw = new StreamWriter("d:\\a-temp1\\data.txt");
tw.WriteLine(trackBar1.Value);
tw.Close();

++qnumber;

if (qnumber == LHSquestions.Length)
{
endMessage();
}
else
{

this.label1.Text = LHSquestions[qnumber];
this.label2.Text = RHSquestions[qnumber];

}
}

private void endMessage()
{
this.label1.Text = "Finished!";
this.label2.Text = "Thank you";
this.button1.Visible = false;
}



Hope this helps.

Nov 17 '05 #4
On Wed, 10 Aug 2005 12:54:19 -0400, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote:
Geoff,

I wouldn't bother writing the values as they are selected (it would be a
pain to "erase" them from your text file if you navigated back and forth).

Rather, I would wait until you have all the values (store them in
memory), and then write them to the file once when the operation is
complete.


OK - makes sense

Cheers

Geoff

Nov 17 '05 #5

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

Similar topics

9
by: Ken | last post by:
I am trying to create one image using JavaScript; then later in the script remove the image - not just remove the src. The following creates the image, but I have been unable to remove it. How...
0
by: mawi | last post by:
Hello, Description: I create panels with some controls on a page using a new panel button. One of the controls on each panel is the "close panel" button that is supposed to close the panel it...
9
by: Charles Law | last post by:
I have a form on which user controls are placed at runtime. When a control is added to the form a handler is added for an event that a high-level object raises, which must be handled by the new...
2
by: =?Utf-8?B?R3JlZw==?= | last post by:
I have the following code the dynamically adds a specific number of controls. for x as integer = 1 to 10 Dim btn as Windows.Forms.Button = New Windows.Forms.Button btn.Name = "btn" & x btn.Text...
3
by: Allen Chen [MSFT] | last post by:
Hi Richard, Quote from Richard================================================== However I also want to be able to remove the panes. I have tried to include this, but find that when I first...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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...
0
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,...
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
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.