Re: Logic Error

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




Tom Spink wrote:

C# newbie with big problems wrote:

Ok, I am building a product configurator which works quite well except
for a few bugs. It has a couple of listboxes and a checked list box.
Now the checked list box holds upgrades for products listed in a
different listbox and these upgrades are grouped by category so for
example if you select a computer then the checked list box may display:

512 RAM
1GB RAM
HDD 30 GB
HDD 60 GB
video...


so, these products are in logical groupings... RAM, HDD, etc. When I
select the checkbox for 1GB RAM then I want to get rid of the checkbox
on 512 RAM and here is where I run into my problem. I decided to give
each member of a group an identifier. Then I created an
ItemCheckChanged event handler. When one of the checks changes I change
all the other checks associated with this group which in turn changes
all the other cheks associated with this group which in turn changes...
you get the idea. This recursive loop never ends and I cant seem to get
the logic working any other way. Any Suggestions on how to fix my
problem? I dont care if there is another type of listbox that may help
or some way to stop logging the remainder of the check changes or even
comming up with some sort of dynamic radio button group thing (because
different items may have different amounts of upgrades and radio
buttons are what I really need here anyway)

thanx
--Roman

Hi Roman,

You could use a flag to indicate that the check is changing:

///
private bool _checkChanging;
private void OnCheckChanged ( object sender, EventArgs e )
{
if ( _checkChanging )
return;

_checkChanging = true;

try
{
// Do Your Processing
}
finally
{
_checkChanging = false;
}
}
///
--
Hope this helps,
Tom Spink

Im not sure that would do me either tom... It seems to me that as soon
as the check changes it will launch the check changed event which will
launch the check changed event and so on... Im starting to think I need
a different way to approach this issue, unless there is a way to stop
logging that the check changes for the second time

.



Relevant Pages

  • Re: Logic Error
    ... 1GB RAM ... I dont care if there is another type of listbox that may help ... private bool _checkChanging; ... and the method will stop executing. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Logic Error
    ... 1GB RAM ... HDD 30 GB ... I dont care if there is another type of listbox that may help ... private bool _checkChanging; ...
    (microsoft.public.dotnet.languages.csharp)
  • Logic Error
    ... Now the checked list box holds upgrades for products listed in a ... 1GB RAM ... HDD 30 GB ... I dont care if there is another type of listbox that may help ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Speeding up XP
    ... prevent other upgrades from being cost effective. ... A Gig or RAM will help as it will alleviate some of the substantial ... If you were going to throw money at some part of the system ... eat away at disk space so you'll be receiving low space warnings fairly ...
    (microsoft.public.windowsxp.general)
  • Re: Added 1GB of RAM; WinXP Media Center asked for Activation?!
    ... No, no other upgrades. ... at which time I upgraded also the video card. ... RAM slots. ... as I plugged the 1GB and rebooted the PC, I was asked to reactive WinXP. ...
    (microsoft.public.windows.mediacenter)