Click here to Skip to main content
15,899,475 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
Questiondesigning a good way enable/disable controls [modified] Pin
giddy_guitarist12-Nov-08 15:18
giddy_guitarist12-Nov-08 15:18 
AnswerRe: designing a good way enable/disable controls Pin
Pete O'Hanlon12-Nov-08 22:30
mvePete O'Hanlon12-Nov-08 22:30 
AnswerRe: designing a good way enable/disable controls Pin
Giorgi Dalakishvili13-Nov-08 0:46
mentorGiorgi Dalakishvili13-Nov-08 0:46 
GeneralRe: designing a good way enable/disable controls Pin
giddy_guitarist13-Nov-08 4:39
giddy_guitarist13-Nov-08 4:39 
GeneralRe: designing a good way enable/disable controls Pin
Ray Cassick14-Nov-08 9:56
Ray Cassick14-Nov-08 9:56 
AnswerRe: designing a good way enable/disable controls Pin
Jani Giannoudis15-Nov-08 5:32
mvaJani Giannoudis15-Nov-08 5:32 
GeneralRe: designing a good way enable/disable controls Pin
Mycroft Holmes15-Nov-08 23:31
professionalMycroft Holmes15-Nov-08 23:31 
AnswerRe: designing a good way enable/disable controls Pin
CodingYoshi15-Nov-08 7:38
CodingYoshi15-Nov-08 7:38 
I think using the MVC pattern is a good solution. I use it all the time. With events the whole process becomes easy.

Create an event in your business object called Validated or something, have the User Interface subscribe to this event. Within the handler put the logic for enabling/disabling control.

Find out ALL the condition which will enable and disable your control and use boolean logic like below:

nameOfButton.Enabled = customer.IsActive && customer.IsValid && someotherCondition || someotherCondition && (someotherCondition || !somotherCondition)

I like this solution because all the rules for the ability of my control are in one spot and the button will only be enabled if all conditions are satisfied.

One thing you want to stay away from is code such as nameOfButton.Enabled = true. Reason being is that somewhere another programmer, or yourself will have another similar call that disables the button. The latest call will actually decide the ability of the button. In situations like this you end up with a lot of if statements and things become very ugly soon.
GeneralRe: designing a good way enable/disable controls Pin
giddy_guitarist15-Nov-08 19:27
giddy_guitarist15-Nov-08 19:27 
GeneralRe: designing a good way enable/disable controls Pin
CodingYoshi15-Nov-08 22:12
CodingYoshi15-Nov-08 22:12 
GeneralRe: designing a good way enable/disable controls Pin
giddy_guitarist15-Nov-08 22:25
giddy_guitarist15-Nov-08 22:25 
QuestionDatabase Engine Independant Data Modelling Pin
Brady Kelly7-Nov-08 5:03
Brady Kelly7-Nov-08 5:03 
AnswerRe: Database Engine Independant Data Modelling Pin
User 17164927-Nov-08 8:00
professionalUser 17164927-Nov-08 8:00 
AnswerRe: Database Engine Independant Data Modelling Pin
Eduardo B16-Nov-08 13:51
Eduardo B16-Nov-08 13:51 
GeneralPart One of a Series on Replicating Validation Logic Between Client and Server [modified] Pin
Brady Kelly7-Nov-08 3:42
Brady Kelly7-Nov-08 3:42 
QuestionHi there :) Please help me Pin
viashivan5-Nov-08 5:05
viashivan5-Nov-08 5:05 
AnswerRe: Hi there :) Please help me Pin
Vimalsoft(Pty) Ltd17-Nov-08 19:55
professionalVimalsoft(Pty) Ltd17-Nov-08 19:55 
QuestionData structure design Pin
hpjchobbes3-Nov-08 5:57
hpjchobbes3-Nov-08 5:57 
AnswerRe: Data structure design Pin
Ray Cassick3-Nov-08 6:13
Ray Cassick3-Nov-08 6:13 
GeneralRe: Data structure design Pin
hpjchobbes3-Nov-08 6:51
hpjchobbes3-Nov-08 6:51 
GeneralRe: Data structure design Pin
Ray Cassick3-Nov-08 7:04
Ray Cassick3-Nov-08 7:04 
AnswerRe: Data structure design Pin
Mark Churchill3-Nov-08 13:56
Mark Churchill3-Nov-08 13:56 
GeneralRe: Data structure design Pin
hpjchobbes4-Nov-08 16:55
hpjchobbes4-Nov-08 16:55 
GeneralRe: Data structure design Pin
Mark Churchill4-Nov-08 17:19
Mark Churchill4-Nov-08 17:19 
AnswerRe: Data structure design Pin
Arash Partow4-Nov-08 23:04
Arash Partow4-Nov-08 23:04 

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.