Re: Going into an infinite loop
From: Justin Rogers (Justin_at_games4dotnet.com)
Date: 11/03/04
- Next message: Scott Allen: "Re: Run an .exe"
- Previous message: Ryan Ternier: "Re: Properties and Events"
- In reply to: Mark Allison: "Going into an infinite loop"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 3 Nov 2004 12:17:13 -0800
You have loads of checks here. What you might want to do is think about
updating an integer or other value based on some bit ordinal... Something
like the following:
int allBits = 0;
allBits = (allBits << 1) + ((chkColumn.Checked) ? 1 : 0);
allBits = (allBits << 1) + ((chkColumn2.Checked) ? 1 : 0);
When you are done, you need to know how many bits you used. The
reason is you are going to & the value.. Above we added 2 bits, so we'll
use the value of 0x3 (11 in binary).
switch(allBits & 0x3) {
case 0x0:
chkAll.Checked = false;
break;
case 0x3:
chkAll.Checked = true;
break;
default:
chkAll.ThreeState = true; chkAll.CheckState = CheckState.Indeterminate;
break;
}
I'm not testing the above code, so there may be some fixes you need to make, but
the concept is solid enough for you to change your program appropriately...
-- Justin Rogers DigiTec Web Consultants, LLC. Blog: http://weblogs.asp.net/justin_rogers "Mark Allison" <marka@no.tinned.meat.mvps.org> wrote in message news:ORiF3ncwEHA.3376@TK2MSFTNGP12.phx.gbl... > Hi, > > I'm a DBA learning C#, so am quite green. > > I have a form http://www.markallison.co.uk/Images/squealfind2.jpg, on the > right there is a group of checkboxes with All Object Types as the header. > > Now, when I check All Object Types, all the other checkboxes take on the > chkAllObjectTypes check value. Great. What I want to happen is when one of the > other check boxes are checked, I want the chkAllObjectTypes checkbox to change > state to > > 1) Indeterminate (tristate) if all other checkboxes are not the same > 2) Change to checked, if all other checkboxes are checked > 3) Change to unchecked, if all other checkboxes are unchecked. > > I've pretty much got 2 and 3 covered, I'm having a little trouble with 1. Code > snapshot: > http://paste.mine.nu/Pastebin/Uploads/paste_01144674226.htm > > Thanks. > > -- > Mark Allison, SQL Server MVP > http://www.markallison.co.uk > > Looking for a SQL Server replication book? > http://www.nwsu.com/0974973602m.html
- Next message: Scott Allen: "Re: Run an .exe"
- Previous message: Ryan Ternier: "Re: Properties and Events"
- In reply to: Mark Allison: "Going into an infinite loop"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|