Click here to Skip to main content
15,913,685 members
Home / Discussions / C#
   

C#

 
GeneralRe: Array of account data Pin
ferronrsmith19-Jan-09 8:53
ferronrsmith19-Jan-09 8:53 
GeneralRe: Array of account data Pin
Not Active19-Jan-09 10:27
mentorNot Active19-Jan-09 10:27 
Question[newbie] controls collection Pin
jon-8019-Jan-09 5:30
professionaljon-8019-Jan-09 5:30 
AnswerRe: [newbie] controls collection Pin
Not Active19-Jan-09 6:10
mentorNot Active19-Jan-09 6:10 
AnswerRe: [newbie] controls collection [modified] Pin
Luc Pattyn19-Jan-09 6:12
sitebuilderLuc Pattyn19-Jan-09 6:12 
GeneralRe: [newbie] controls collection Pin
jon-8019-Jan-09 12:27
professionaljon-8019-Jan-09 12:27 
AnswerRe: [newbie] controls collection [modified] Pin
Luc Pattyn19-Jan-09 12:42
sitebuilderLuc Pattyn19-Jan-09 12:42 
AnswerRe: [newbie] controls collection Pin
Ben Fair19-Jan-09 6:15
Ben Fair19-Jan-09 6:15 
For the button text, you could use a Boolean field, let's say it could be named createNewTask and is initialized to true. Then, in the button's click handler you can toggle the Boolean field. Also if you make a Property for the Boolean field, then you can put the setting of the button's Text property in the Set of the Boolean Property; make sense? Like this:

public partial class ... : Form (Page? for ASP.NET)
{
    ....
    private bool createNewTask = true;
    private bool CreateNewTask
    {
        get { return createNewTask; }
        set 
        { 
            if(createNewTask != value) // value being changed?
            {
                createNewTask = value;
                if(createNewTask)
                    btnCreateNewTask.Text = "Create";
                else
                    btnCreateNewTask.Text = "Update";
                btnCreateNewTask.Text += " new task";
            }
        }
    }
    ....
}


I don't use textual comparison of a control's Text property to control the state of a control, just personal preference. Plus, I think making a Property and linking the Property's Set method with the visual changing of the control's state is really intuitive and makes it easy to maintain if you have to expand on it later. If you find yourself having more than 2 possible values (maybe the button needs to function in 3 different ways instead of 2), then use an Enum to define the different ways it can work and put a Property around a private Enum field with a switch in the Set of the Property; similar to how I did it with a Boolean above.

Keep It Simple Stupid! (KISS)

GeneralRe: [newbie] controls collection Pin
Not Active19-Jan-09 6:27
mentorNot Active19-Jan-09 6:27 
GeneralRe: [newbie] controls collection Pin
Ben Fair19-Jan-09 15:23
Ben Fair19-Jan-09 15:23 
QuestionFind out the path of a file in a c#-program, the user has double-clicked in the explorer Pin
tschmid8519-Jan-09 5:02
tschmid8519-Jan-09 5:02 
AnswerRe: Find out the path of a file in a c#-program, the user has double-clicked in the explorer [modified] Pin
Luc Pattyn19-Jan-09 5:16
sitebuilderLuc Pattyn19-Jan-09 5:16 
GeneralRe: Find out the path of a file in a c#-program, the user has double-clicked in the explorer Pin
tschmid8520-Jan-09 0:07
tschmid8520-Jan-09 0:07 
AnswerRe: Find out the path of a file in a c#-program, the user has double-clicked in the explorer [modified] Pin
Luc Pattyn20-Jan-09 1:02
sitebuilderLuc Pattyn20-Jan-09 1:02 
AnswerRe: Find out the path of a file in a c#-program, the user has double-clicked in the explorer Pin
Pete O'Hanlon19-Jan-09 5:19
mvePete O'Hanlon19-Jan-09 5:19 
AnswerRe: Find out the path of a file in a c#-program, the user has double-clicked in the explorer [modified] Pin
Luc Pattyn19-Jan-09 6:18
sitebuilderLuc Pattyn19-Jan-09 6:18 
GeneralRe: Find out the path of a file in a c#-program, the user has double-clicked in the explorer Pin
Pete O'Hanlon19-Jan-09 8:41
mvePete O'Hanlon19-Jan-09 8:41 
AnswerRe: Find out the path of a file in a c#-program, the user has double-clicked in the explorer Pin
Giorgi Dalakishvili19-Jan-09 5:28
mentorGiorgi Dalakishvili19-Jan-09 5:28 
QuestionSQL Relations Pin
ctrlnick19-Jan-09 4:56
ctrlnick19-Jan-09 4:56 
AnswerRe: SQL Relations Pin
Not Active19-Jan-09 5:01
mentorNot Active19-Jan-09 5:01 
GeneralRe: SQL Relations Pin
ctrlnick19-Jan-09 5:04
ctrlnick19-Jan-09 5:04 
GeneralRe: SQL Relations Pin
Not Active19-Jan-09 5:14
mentorNot Active19-Jan-09 5:14 
GeneralRe: SQL Relations Pin
ctrlnick19-Jan-09 6:55
ctrlnick19-Jan-09 6:55 
GeneralRe: SQL Relations Pin
Not Active19-Jan-09 7:01
mentorNot Active19-Jan-09 7:01 
AnswerRe: SQL Relations Pin
Wendelius19-Jan-09 7:40
mentorWendelius19-Jan-09 7:40 

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.