473,396 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

c# Event problem (Let me know this is event problem or not..)

Please anybody help me...

I have some serious problem..
I'm doing to keep equpiment list(string)..
In my code, there are 3 page which are having 4 equpiment ID (user
control.)
like this window FORM
================================================== ================
=
= ============= ============= ============= =============
= = equpment ID = = equpment ID = = equpment ID = =
equpment ID =
= = combo box = = combo box = = combo box = =
combo box =
= = (user object) = = (user object) = = (user object)
= = (user object) =
= ============= ============= ============= =============
=
=
=
= PAGE 1 BUTTON PAGE 2 BUTTON PAGE 3 BUTTON
================================================== ==================
every userobject can select equpiment (1000,2000,3000 or 4000)
every page has 4 equpment list, so totally 12 equpment can be display
at once..
1. when combo box click(means equipment change), event is occured
2. FORM window catch event and keep equipment inforamtion at
dictionary<int, list<String>>
(int is page number, string is equipment ID)
3. if page changed, display thier (page) own equipment list
The problem is ... event...
I select 1000, 2000 ," ", " " at page 1
and change page to 2 (all user control clear because page 2 is not
select any equipment)
I select " ", 3000,4000, " " at page 2
I return select page 1
I expected 1000, 2000, " " ," " but.. result is 1000,2000,4000, " "
I do not know whay 4000 is displayed...
So i debug code...
the event was problem
I code like following...
private void comboBox1_SelectedIndexChanged_1(object sender,
EventArgs
e)
{
equipmentID = comboBox1.Text;
equipmentChanged(new object(), new EventArgs());
//equipmentChanged(this, new EventArgs());
}
equipmentChanged is event...

If I comment out equipmentChanged event and calll event by other, the
problem is not happened...
(example I made a button on usercontrol and send event by button
click)
I want to attach the sample code but I don't know how to attach at
this usernet group..
So please down load my c# sample code and please teach me what is
problem...

http://download.yousendit.com/B1F068D56D804070
there is testWindow.zip file at that site..

I tooks 1 day to resolve this problem but I still could not found
reason..
Please.. please.. please...

Jun 19 '07 #1
3 1787
On Mon, 18 Jun 2007 17:54:04 -0700, <ct*****@gmail.comwrote:
[...]
http://download.yousendit.com/B1F068D56D804070
there is testWindow.zip file at that site..

I tooks 1 day to resolve this problem but I still could not found
reason..
Nor is it clear that you've resolved the issue in a satisfactory manner.

In any case, the problem happens because when you change the value of a
ComboBox, that can cause the SelectedIndexChanged event to be signaled.
In your code, when the SelectedIndexChanged event is signaled, you copy
_all_ of the current values of the ComboBox instances (via your user
control) to the current page's list of values. Of course, since you've
already changed the current page number by that point, you wind up taking
the current value of each of the ComboBox instances beyond what you've
already updated and copying those into your current page.

This is easily seen in the debugger by noting that your userControlList
for the given page does match what each ComboBox is showing you. So then
you set a breakpoint where you change the userControlList for the given
page and note that when you switch back to page 1, you actually wind up in
the EquipmentChanged() method copying values from each user control into
your current page's userControlList. This is the point at which the value
from the ComboBox on the previous page is copied to the userControlList
for the current page. And of course, moments later, you then take that
changed value to update the ComboBox again.

I think you would be well-served by practicing this scenario and others in
the debugger, so that you are better at using the debugger. IMHO, simply
putting appropriate breakpoints in the debugger and watching what happens
to your data makes it very clear what's wrong with your code.

How to fix it is another matter, but I would say as a start it is not a
good idea to copy _all_ of your values when just _one_ has changed. You
have a variety of other things that I would fix in your code, but it's
that one behavior that's causing the specific problem you're asking about.

Pete
Jun 19 '07 #2
On Mon, 18 Jun 2007 17:54:04 -0700, <ct*****@gmail.comwrote:
Please anybody help me...
And for the record...

I replied to your post _in spite of_ the number of times you posted it,
rather than _because of_ the number of times you posted it. My usual
reaction to seeing that number of repeats is to just ignore the post
altogether.
Jun 19 '07 #3
On 6 19 , 10 56 , "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
On Mon, 18 Jun 2007 17:54:04 -0700, <cty0...@gmail.comwrote:
[...]
http://download.yousendit.com/B1F068D56D804070
there is testWindow.zip file at that site..
I tooks 1 day to resolve this problem but I still could not found
reason..

Nor is it clear that you've resolved the issue in a satisfactory manner.

In any case, the problem happens because when you change the value of a
ComboBox, that can cause the SelectedIndexChanged event to be signaled.
In your code, when the SelectedIndexChanged event is signaled, you copy
_all_ of the current values of the ComboBox instances (via your user
control) to the current page's list of values. Of course, since you've
already changed the current page number by that point, you wind up taking
the current value of each of the ComboBox instances beyond what you've
already updated and copying those into your current page.

This is easily seen in the debugger by noting that your userControlList
for the given page does match what each ComboBox is showing you. So then
you set a breakpoint where you change the userControlList for the given
page and note that when you switch back to page 1, you actually wind up in
the EquipmentChanged() method copying values from each user control into
your current page's userControlList. This is the point at which the value
from the ComboBox on the previous page is copied to the userControlList
for the current page. And of course, moments later, you then take that
changed value to update the ComboBox again.

I think you would be well-served by practicing this scenario and others in
the debugger, so that you are better at using the debugger. IMHO, simply
putting appropriate breakpoints in the debugger and watching what happens
to your data makes it very clear what's wrong with your code.

How to fix it is another matter, but I would say as a start it is not a
good idea to copy _all_ of your values when just _one_ has changed. You
have a variety of other things that I would fix in your code, but it's
that one behavior that's causing the specific problem you're asking about.

Pete
I have finally found out the problem and fix it by your teaching
Thanks thanks thankssssssss alot...
Jun 19 '07 #4

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

Similar topics

3
by: Steve Long | last post by:
Hello, I have a VB.NET class that raises a MapSet event that passes an argument of type interop.MapObjects2.MapClass. I have a C# class that inherits from this VB.NET class. How can I handle the...
2
by: Wavemaker | last post by:
The canonical way of declaring delegates for events is to include a parameter representing the sender as well as an EventArgs derived class (or EventArgs itself) as the second parameter...
5
by: Carlo Marchesoni | last post by:
From an aspx page (A.aspx) I open another one (B.aspx - for table lookup). When the user selects an entry in B.aspx I would like to force a button's event in A.aspx to be fired. I guess the only...
3
by: R Millman | last post by:
under ASP.NET, single stepping in debug mode appears not to stop within event procedures. i.e. 1) Create web page with submit button and event procedure for the click event in the code behind...
19
by: Heidi Hundåla | last post by:
Hi ! I have a Wep App in C#. Page_Unload fires after Page_Load, and it seems totally unreasonable when you want to use this event when you _leave_ the page. In my project we wanted to use...
29
by: Patrick | last post by:
I have the following code, which regardless which works fine and logs to the EventViewer regardless of whether <processModel/> section of machine.config is set to username="SYSTEM" or "machine" ...
3
by: bclegg | last post by:
Hi, I am trying to use a 3rd Party telephony (Intel's CT-ADE 8.3) library in a vb.net service. The way it hangs up is to raise an Event. If you build a windows Application you can write: Sub...
5
by: Paul Bromley | last post by:
Can someone give me a very simple example on how to do this? As an example I have a commaned button in a user control. Once this user control is placed on a form I want to be able to respond in the...
13
by: Charles Law | last post by:
Mr "yEaH rIgHt" posted the following link about a week ago in answer to my question about removing event handlers. > http://www.vbinfozine.com/t_bindevt.shtml Following on from that post, the...
4
by: AzizMandar | last post by:
C++ Event Coding Questions I have done some simple programs in C++ and read a lot of good C++ books (Including The C++ Programing Language, and C++ Primer) I am trying to understand and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.