Click here to Skip to main content
15,886,362 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# windows forms sent data to a link and preview them with PHP on IE or Safari etc. Pin
BobJanova10-Jun-12 22:58
BobJanova10-Jun-12 22:58 
GeneralRe: C# windows forms sent data to a link and preview them with PHP on IE or Safari etc. Pin
Vvelawras10-Jun-12 23:04
Vvelawras10-Jun-12 23:04 
GeneralRe: C# windows forms sent data to a link and preview them with PHP on IE or Safari etc. Pin
BobJanova11-Jun-12 5:54
BobJanova11-Jun-12 5:54 
QuestionReceive post values from Windows form app C# with php Pin
Vvelawras10-Jun-12 9:18
Vvelawras10-Jun-12 9:18 
QuestionEnable multiple textboxes one by one on button click Pin
Saidrex10-Jun-12 6:17
Saidrex10-Jun-12 6:17 
AnswerRe: Enable multiple textboxes one by one on button click Pin
Richard Andrew x6410-Jun-12 7:11
professionalRichard Andrew x6410-Jun-12 7:11 
GeneralRe: Enable multiple textboxes one by one on button click Pin
Saidrex10-Jun-12 8:01
Saidrex10-Jun-12 8:01 
AnswerRe: Enable multiple textboxes one by one on button click Pin
DaveyM6910-Jun-12 10:13
professionalDaveyM6910-Jun-12 10:13 
Perhaps add them to a list and maintain a counter so you can enable the next one?
C#
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 // etc...
            });
        }

        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:
C#
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;
        }
    }
}

Dave

Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.
Astonish us. Be exceptional. (Pete O'Hanlon)

BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)




modified 10-Jun-12 16:21pm.

GeneralRe: Enable multiple textboxes one by one on button click Pin
Saidrex10-Jun-12 11:37
Saidrex10-Jun-12 11:37 
GeneralRe: Enable multiple textboxes one by one on button click Pin
BobJanova10-Jun-12 22:50
BobJanova10-Jun-12 22:50 
GeneralRe: Enable multiple textboxes one by one on button click Pin
Saidrex10-Jun-12 23:07
Saidrex10-Jun-12 23:07 
Questionc# Pin
gopalmahadak9-Jun-12 17:34
gopalmahadak9-Jun-12 17:34 
AnswerRe: c# Pin
Richard Andrew x649-Jun-12 17:52
professionalRichard Andrew x649-Jun-12 17:52 
AnswerRe: c# Pin
PIEBALDconsult9-Jun-12 19:43
mvePIEBALDconsult9-Jun-12 19:43 
AnswerRe: c# Pin
OriginalGriff9-Jun-12 20:10
mveOriginalGriff9-Jun-12 20:10 
GeneralRe: c# Pin
glennPattonWork310-Jun-12 22:20
professionalglennPattonWork310-Jun-12 22:20 
AnswerRe: c# Pin
Dave Kreskowiak10-Jun-12 4:32
mveDave Kreskowiak10-Jun-12 4:32 
GeneralRe: c# Pin
egenis10-Jun-12 5:23
egenis10-Jun-12 5:23 
GeneralRe: c# Pin
Dave Kreskowiak10-Jun-12 6:59
mveDave Kreskowiak10-Jun-12 6:59 
AnswerRe: c# Pin
Abhinav S10-Jun-12 17:18
Abhinav S10-Jun-12 17:18 
Questionpaint event not called Pin
Danzy839-Jun-12 8:19
Danzy839-Jun-12 8:19 
AnswerRe: paint event not called Pin
OriginalGriff9-Jun-12 20:11
mveOriginalGriff9-Jun-12 20:11 
QuestionUser privilege issue logged on user (non local system account) Pin
Sunil P V8-Jun-12 20:13
Sunil P V8-Jun-12 20:13 
AnswerRe: User privilege issue logged on user (non local system account) Pin
Dave Kreskowiak9-Jun-12 5:11
mveDave Kreskowiak9-Jun-12 5:11 
GeneralRe: User privilege issue logged on user (non local system account) Pin
Sunil P V9-Jun-12 18:07
Sunil P V9-Jun-12 18:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.