473,382 Members | 1,437 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,382 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 1781
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.