|
Perhaps add them to a list and maintain a counter so you can enable the next one?
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace WindowsFormsTestApp
{
public partial class Form1 : Form
{
private List<TextBox> textBoxes;
private int textBoxCounter = 0;
public Form1()
{
InitializeComponent();
textBoxes = new List<TextBox>(new TextBox[]{
textBox1,
textBox2,
textBox3
});
}
private void button1_Click(object sender, EventArgs e)
{
textBoxes[textBoxCounter].Enabled = true;
textBoxCounter++;
if (textBoxCounter == textBoxes.Count)
button1.Enabled = false;
}
}
}
Edit:
If you only need to do this once, a Queue<T> would be better and you won't need the counter:
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace WindowsFormsTestApp
{
public partial class Form1 : Form
{
private Queue<TextBox> textBoxes;
public Form1()
{
InitializeComponent();
textBoxes = new Queue<TextBox>(new TextBox[]{
textBox1,
textBox2,
textBox3
});
}
private void button1_Click(object sender, EventArgs e)
{
textBoxes.Dequeue().Enabled = true;
button1.Enabled = textBoxes.Count > 0;
}
}
}
modified 10-Jun-12 16:21pm.
|
|
|
|
|
Tried both examples, they don't work with my program, maybe i'm doing something wrong. When i click button nothing happens.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace datori_konf
{
public partial class datoru_konf : Form
{
private Queue<TextBox> textBoxes;
public datoru_konf()
{
InitializeComponent();
textBoxes = new Queue<TextBox>(new TextBox[]{
prog1,
prog2,
prog3,
prog4,
prog5,
prog6,
prog7,
prog8,
prog9,
prog10,
prog11,
prog12,
prog13,
prog14,
prog15,
prog16,
prog17,
prog18,
prog19,
prog20
});
}
private void button4_Click(object sender, EventArgs e)
{
this.Close();
}
private void button2_Click(object sender, EventArgs e)
{
Form2 form = new Form2();
form.ShowDialog();
}
private void button1_Click(object sender, EventArgs e)
{
textBoxes.Dequeue().Enabled = true;
button1.Enabled = textBoxes.Count > 0;
}
}
}
|
|
|
|
|
That looks okay. Did you actually hook up the click event to that method?
|
|
|
|
|
no my mistake, now it works, thanks. Thanks everyone who helped, you are the best 
|
|
|
|
|
i want the project which uses tdbgrid in it....
please guide me....
|
|
|
|
|
Have you tried Google?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
What's a "tdbgrid"? 
|
|
|
|
|
Start reading: TDBGrid[^]
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Just checked the link, looks like I might find it useful for some data display, is this a case of 'gimme code plz being useful'?
|
|
|
|
|
gopalmahadak wrote: i want
You sound my like 4 year old son.
|
|
|
|
|
At our kids say "please"!
|
|
|
|
|
He only says it when he sees something on TV he wants.
|
|
|
|
|
Check on the third party control's website. Im sure you will find a lot of information.
|
|
|
|
|
Hi all, I want to draw the contents of a TableLayoutPanel control on a printer page. When I call Invalidate() of the control, the paint event is not called. The drawing therefore becomes blank. Calling its Refresh() function does not also help.
However, if I call its DrawToBitmap(), the paint event is called. Is there a way I can get the Paint event called so that I can draw on the printer page without creating a Bitmap out of it before? Thanks in advance
|
|
|
|
|
Show us the relevant code fragments: DrawToBitmap, the Paint handler and the Invalidate code - remember to give us a a few line either side for context.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Hi,
I have a desktop application that is executed with Admin privileges. When this application is run by a non-admin user (by elevating the app with admin rights) say standard user, I am unable to get the standard user's (or logged on user's) environment variables, instead the application returns the Admin users environment variable. How can this issue be resolved. Please help...
Sunil
|
|
|
|
|
sunilkpv wrote: When this application is run by a non-admin user (by elevating the app with
admin rights)
That's exactly what's supposed to happen. The app will run as the Admin user and get the Admin users variables. You cannot get the logged on users variables as that person did not launch the app and, hence, the app did not inherit the normal users environment.
|
|
|
|
|
Thanks Dave.
But is there a way to hack this. I want the logged on user's environment variables even though the application is invoked as an admin user. I suppose impersonation would not work because the admin account does not fall under local system account...
Sunil
|
|
|
|
|
No, there's no "hack" for this.
What are you doing that requires an admin account?
Impersonation won't work because then you're using the users account, which pretty much makes launch as an admin a moot point.
|
|
|
|
|
hi my friend pleas help me, how can i show value of Thermometer which component like Thermometer and i show value,Thanks for help
|
|
|
|
|
Your question isn't clear at all. We have no idea what part of this you're having a problem with.
Can you get the value from the thermometer? Are you having a problem with a component? Did you make you're own control to display the value in what looks like a thermometer??
|
|
|
|
|
|
Hi all,
I want to make this piece of code more simple:
enum selectSentMode { sent, notSent, sentError }
int sentStatus;
private void portExt_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Other code ..........
if (sendIndex > 512)
{
sentStatus=(int) selectSentMode.sent;
}
else if (sendIndex == 0)
{
sentStatus = (int)selectSentMode.notSent;
}
else
{
sentStatus = (int)selectSentMode.sentError;
}
}
}
private void tmrPortExt_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
Code........
switch (sentStatus)
{
case(int) selectSentMode.sent:
DoSomthing;
break;
case(int) selectSentMode.notSent:
DoSomthing;
break;
case(int) selectSentMode.sentError:
ErrorHandling;
break;
default:
break;
}
}
what I want is something like this:
selectSentMode { sent, notSent, sentError }
private void portExt_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Other code ..........
if (sendIndex > 512)
{
selectSentMode = sent;
}
else if (sendIndex == 0)
{
selectSentMode=notSent;
}
else
{
selectSentMode=sentError;
}
}
}
private void tmrPortExt_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
Code........
switch (selectSentMode)
{
case sent:
DoSomthing;
break;
case notSent:
DoSomthing;
break;
case sentError:
ErrorHandling;
break;
default:
break;
}
}
Hope someone can help
Groover.
modified 8-Jun-12 16:41pm.
|
|
|
|
|
Can you please repost using <pre> </pre> tags?
/ravi
|
|
|
|
|
You're almost there, you just need to correct the syntax.
enum selectSentMode { sent, notSent, sentError }
selectSentMode sentStatus ;
sentstatus = selectSentMode.sent ;
switch ( sentstatus )
case selectSentMode.sent :
|
|
|
|