473,561 Members | 3,118 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

changing UI state generate UI events

Hello,

When we update an UI control by code, that control generates a event.
For example, if we make a CheckBox Checked, then the CheckedChanged event is fired.
That is a goog behavior, but not at the first time (initialization ).

Here the scenario :

<code>
SomeObject data ;
....
void UpdateData2UI()
{
this.checkbox.c hecked = data.IsPlaying ;
}
void checkbox_Checke dChanged(...)
{
data.IsPlaying = this.checkbox.c hecked ;
}
</code>

At UI initialization data.IsPlaying is "read" then "write" without necessity.
It could be a bad stuff if data.IsPlaying has to do some stuff.

Is the only solution is to add a test in checkbox_Checke dChanged ??
Like :
<code>
void checkbox_Checke dChanged(...)
{
if( this.checkbox.c hecked != data.IsPlaying )
{
data.IsPlaying = this.checkbox.c hecked ;
}
}
</code>

How do you do for that situation ?

I hope my explanation are clear enough ...

cyrille
Feb 3 '06 #1
6 1695
"# Cyrille37 #" <cy*******@free .fr> a écrit dans le message de news:
ed************* *@TK2MSFTNGP14. phx.gbl...

| When we update an UI control by code, that control generates a event.
| For example, if we make a CheckBox Checked, then the CheckedChanged event
is fired.
| That is a goog behavior, but not at the first time (initialization ).

You really ought to make the UI update itself based on the state of the
object, not the other way around. Try to set the Checked state based on the
IsPlaying property when you initialise the form.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Feb 3 '06 #2
Joanna Carter [TeamB] :
"# Cyrille37 #" <cy*******@free .fr> a écrit dans le message de news:
ed************* *@TK2MSFTNGP14. phx.gbl...

| When we update an UI control by code, that control generates a event.
| For example, if we make a CheckBox Checked, then the CheckedChanged event
is fired.
| That is a goog behavior, but not at the first time (initialization ).

You really ought to make the UI update itself based on the state of the
object, not the other way around. Try to set the Checked state based onthe
IsPlaying property when you initialise the form.


thanks for your help.

That is the form (an UserControl in fact) is always present.
In another UserControl when selected a Item in a TreeView, I'm refreshingdata.
So the Checked state could not be set in Form/UserControl initialization.

cyrille

Feb 3 '06 #3
"# Cyrille37 #" <cy*******@free .fr> a écrit dans le message de news:
e3************* *@TK2MSFTNGP12. phx.gbl...

| That is the form (an UserControl in fact) is always present.
| In another UserControl when selected a Item in a TreeView, I'm refreshing
data.
| So the Checked state could not be set in Form/UserControl initialization.

Then I would suggest that you hold a local variable that is set to the
selected item in the TreeView. In the event handler that detects the change
in the TreeView, you can then set the local variable and update the
CheckBox.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Feb 3 '06 #4
Joanna Carter [TeamB] a écrit :
"# Cyrille37 #" <cy*******@free .fr> a écrit dans le message de news:
e3************* *@TK2MSFTNGP12. phx.gbl...

| That is the form (an UserControl in fact) is always present.
| In another UserControl when selected a Item in a TreeView, I'm refreshing
data.
| So the Checked state could not be set in Form/UserControl initialization.

Then I would suggest that you hold a local variable that is set to the
selected item in the TreeView. In the event handler that detects the change
in the TreeView, you can then set the local variable and update the
CheckBox.
Yes, it's what I do.
But when I'm updating the checkbox, in response the checkbox fire an event which
update data ... The only solution I've found is to compare checkbox stateand
data state, if they are different I update data.

cyrille

Joanna


Feb 3 '06 #5
SP

"# Cyrille37 #" <cy*******@free .fr> wrote in message
news:ed******** ******@TK2MSFTN GP14.phx.gbl...
Hello,

When we update an UI control by code, that control generates a event.
For example, if we make a CheckBox Checked, then the CheckedChanged event
is fired.
That is a goog behavior, but not at the first time (initialization ).

Here the scenario :

<code>
SomeObject data ;
...
void UpdateData2UI()
{
this.checkbox.c hecked = data.IsPlaying ;
}
void checkbox_Checke dChanged(...)
{
data.IsPlaying = this.checkbox.c hecked ;
}
</code>

At UI initialization data.IsPlaying is "read" then "write" without
necessity.
It could be a bad stuff if data.IsPlaying has to do some stuff.

Is the only solution is to add a test in checkbox_Checke dChanged ??
Like :
<code>
void checkbox_Checke dChanged(...)
{
if( this.checkbox.c hecked != data.IsPlaying )
{
data.IsPlaying = this.checkbox.c hecked ;
}
}
</code>

How do you do for that situation ?


There are a few options. One is to set the event handlers not at design time
but at run time. Then the order of displaying your data is remove handlers,
update your controls and then add the handlers. Second option is to have a
bool flag like loadingData that you check in each event handler like
if(loadingData) return;. Third option is to use another event like Leave on
some controls where it is not really necessary for the changes that are made
to immediately update the state of your application but rather update when
the user has finished and leaves the control to do something else so the
Leave indicates "I have finished".

HTH

SP
Feb 3 '06 #6
SP a écrit :
"# Cyrille37 #" <cy*******@free .fr> wrote in message
news:ed******** ******@TK2MSFTN GP14.phx.gbl...
Hello,

When we update an UI control by code, that control generates a event.
For example, if we make a CheckBox Checked, then the CheckedChanged event
is fired.
That is a goog behavior, but not at the first time (initialization ).

How do you do for that situation ?


There are a few options. One is to set the event handlers not at designtime
but at run time. Then the order of displaying your data is remove handlers,
update your controls and then add the handlers. Second option is to have a
bool flag like loadingData that you check in each event handler like
if(loadingData) return;. Third option is to use another event like Leave on
some controls where it is not really necessary for the changes that aremade
to immediately update the state of your application but rather update when
the user has finished and leaves the control to do something else so the
Leave indicates "I have finished".

Thank you very much for your clear explanation of choices.

Now I've material for thinking ;o)

bye
cyrille

Feb 3 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3967
by: iwearwatches | last post by:
Group, What a root canal. Here is what I have: I have a page that has several layers that I will either show/hide based on a graphic/tab that the user clicks. (works perfectly)
2
2620
by: ColinWard | last post by:
Hi. I have a form which has as its recordsource an SQL string. The SQL String is as follows: SELECT * from CONTACTS where false. this ensures that there is no data loaded in the form when the form is opened. After the user selects the contact from an unbound combobox I want the form to be rebound to its recordsource. I tried using...
7
8494
by: Nicolae Fieraru | last post by:
Hi All, I am trying to change the rowsource of a combobox when I click on it. I played with many events, associated with the form and the combobox, but still haven't figured out what is the way of doing it. I have a table with products, tblProducts, some of them are Active while others are Inactive. The form shows all the products...
4
11835
by: KK | last post by:
Hi All... For my purpose, I need to handle listbox selection changed event.I must be notified before changing occurs and after.After I can handle using SelectedIndexChanged event.Is there anyway to know which one is selected item before this event.?One thing is I can have a variable to hold the index in my application. I'm looking exactly...
5
548
by: Sean | last post by:
Problem with sessions I have created an application without concern for sessions. As it turns out I think that might be my undoing. What I have: I have an online quiz. I don’t need to know users or save any data. If the application crashes or user exits the program they should simply start again. Pretty basic. All interactions are...
8
5802
by: Bill Rust | last post by:
I've created an "Add Item" wizard for VB.NET 2003 that allows a user to add a specialized class that works with my application framework. In the wizard, the user can select the interfaces they would like to support. During the code generation phase, I add an "Implements Ixxx" for each interface they select, but I've not yet figured out how...
4
6624
by: Jon Slaughter | last post by:
Is there any method to temporarily disable focus changing?(I assume only method is tab or mouse?) This problem has been tieing me up for a while and nothing seems to work. The only thing that I *know* will work is to disable all tab stops on all controls. This brute force method doesn't seem like a good idea though. What I wanted to do was...
3
2878
by: thomson | last post by:
Hi All, i do have an website with the URL http://localhost/application/ASEAN-ANZ, Once i hit the application, it goes to the Global.asax. but after that if i tried to change the URL http://localhost/application/en-US, the global.asax is not fired.
3
1638
by: galathaea | last post by:
it surprises me how often engineers confuse states with actions i think this is the fundamental reification behind procedural statemess and this mistake infects a lot of great projects with entropising debate this error is the type of complexity growing belief that changes a simple state transition o -------o to clever decompositions...
0
7637
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7558
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8072
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7605
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7924
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5462
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5177
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3591
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.