Click here to Skip to main content
15,896,063 members
Home / Discussions / C#
   

C#

 
GeneralRe: using different interfaces still works! Pin
Colin Angus Mackay21-Jul-04 23:52
Colin Angus Mackay21-Jul-04 23:52 
GeneralOne major tcp/ip headache Pin
TalkingBabb0t21-Jul-04 17:10
TalkingBabb0t21-Jul-04 17:10 
GeneralRe: One major tcp/ip headache Pin
Heath Stewart22-Jul-04 3:56
protectorHeath Stewart22-Jul-04 3:56 
GeneralRe: One major tcp/ip headache Pin
TalkingBabb0t22-Jul-04 16:19
TalkingBabb0t22-Jul-04 16:19 
GeneralAbout C# Rs232 communication Pin
resocman21-Jul-04 17:09
resocman21-Jul-04 17:09 
GeneralRe: About C# Rs232 communication Pin
Heath Stewart22-Jul-04 3:46
protectorHeath Stewart22-Jul-04 3:46 
GeneralRe: About C# Rs232 communication Pin
resocman22-Jul-04 19:59
resocman22-Jul-04 19:59 
GeneralEvents and Model Logic Pin
Leslie Sanford21-Jul-04 16:44
Leslie Sanford21-Jul-04 16:44 
Here is an issue I've run into from time to time while creating C# applications. Let's say I have a model which represents the business domain of my application. To present this model to my users, I have a GUI layer.

Let's say that there is a combo box that is a part of the GUI. The user clicks on the combo box and makes a selection. This triggers an event. In response to this event, the model is updated.

Very, very simple. But...

When updating the model from an outside source, say a file or whatever, the GUI will need to be updated to represent the model accurately. Continuing with the combo box example, if you set the SelectedIndex property to a value programmically, an event will be raised to indicate that the property has changed. So when updating the GUI, events are raised in response. And using the logic set up to respond to those events, the model will be updated unnecessarily.

In the case of the ComboBox and its SelectedIndex property, there is no distinction made between the property being modified as a result of user interaction and being modified programmically.

One obvious approach would be to disconnect from the events when you don't want to respond to them and reconnect afterwards. But with a lot of controls, that could lead to a lot of code. What this has led me to do is to use a boolean variable to indicate whether or not the model should be updated when an event is raised by the GUI controls. But this solution feels kludgish.

I was wondering if other C# programmers have run into this problem and how you dealt with it.
GeneralRe: Events and Model Logic Pin
Heath Stewart22-Jul-04 3:43
protectorHeath Stewart22-Jul-04 3:43 
Generalpassing a form control to a class Pin
budha_man_9921-Jul-04 11:51
budha_man_9921-Jul-04 11:51 
GeneralRe: passing a form control to a class Pin
Colin Angus Mackay21-Jul-04 14:06
Colin Angus Mackay21-Jul-04 14:06 
GeneralRe: passing a form control to a class Pin
budha_man_9922-Jul-04 4:50
budha_man_9922-Jul-04 4:50 
GeneralRe: passing a form control to a class Pin
Colin Angus Mackay22-Jul-04 5:21
Colin Angus Mackay22-Jul-04 5:21 
GeneralRe: passing a form control to a class Pin
budha_man_9922-Jul-04 5:28
budha_man_9922-Jul-04 5:28 
Generalresize tabPages problem Pin
Andy H21-Jul-04 11:32
Andy H21-Jul-04 11:32 
Generalcolor button example Pin
ddelapasse21-Jul-04 9:20
ddelapasse21-Jul-04 9:20 
GeneralRe: color button example Pin
Gary Thom21-Jul-04 9:58
Gary Thom21-Jul-04 9:58 
GeneralRe: color button example Pin
Anonymous21-Jul-04 10:29
Anonymous21-Jul-04 10:29 
GeneralRe: color button example Pin
Gary Thom22-Jul-04 9:41
Gary Thom22-Jul-04 9:41 
Generalcut/copy/paste/undo Pin
HappyPaws21-Jul-04 8:36
HappyPaws21-Jul-04 8:36 
GeneralRe: cut/copy/paste/undo Pin
Heath Stewart21-Jul-04 9:18
protectorHeath Stewart21-Jul-04 9:18 
GeneralRe: cut/copy/paste/undo Pin
Gary Thom21-Jul-04 10:04
Gary Thom21-Jul-04 10:04 
GeneralRe: cut/copy/paste/undo Pin
Jay Shankar21-Jul-04 22:36
Jay Shankar21-Jul-04 22:36 
QuestionCan you pass parameters to properties? Pin
inyoursadachine21-Jul-04 7:11
inyoursadachine21-Jul-04 7:11 
AnswerRe: Can you pass parameters to properties? Pin
Gary Thom21-Jul-04 8:27
Gary Thom21-Jul-04 8:27 

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.