Click here to Skip to main content
15,892,643 members
Home / Discussions / C#
   

C#

 
GeneralRe: Am I doing this right..... Pin
glennPattonWork311-Jun-12 4:40
professionalglennPattonWork311-Jun-12 4:40 
AnswerRe: Am I doing this right..... Pin
BobJanova11-Jun-12 5:56
BobJanova11-Jun-12 5:56 
GeneralRe: Am I doing this right..... Pin
glennPattonWork311-Jun-12 6:00
professionalglennPattonWork311-Jun-12 6:00 
Questionping from Windows-Mobile in C# Pin
goldsoft10-Jun-12 22:30
goldsoft10-Jun-12 22:30 
AnswerRe: ping from Windows-Mobile in C# Pin
Pete O'Hanlon10-Jun-12 22:42
mvePete O'Hanlon10-Jun-12 22:42 
QuestionTaking voice input in C# in Visual Studio Pin
Namus Adhikari10-Jun-12 20:40
Namus Adhikari10-Jun-12 20:40 
AnswerRe: Taking voice input in C# in Visual Studio Pin
Abhinav S10-Jun-12 20:46
Abhinav S10-Jun-12 20:46 
QuestionC# windows forms sent data to a link and preview them with PHP on IE or Safari etc. Pin
Vvelawras10-Jun-12 9:24
Vvelawras10-Jun-12 9:24 
AnswerRe: C# windows forms sent data to a link and preview them with PHP on IE or Safari etc. Pin
Abhinav S10-Jun-12 17:20
Abhinav S10-Jun-12 17:20 
GeneralRe: C# windows forms sent data to a link and preview them with PHP on IE or Safari etc. Pin
Vvelawras10-Jun-12 21:58
Vvelawras10-Jun-12 21:58 
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 

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.