Click here to Skip to main content
15,913,487 members
Home / Discussions / C#
   

C#

 
QuestionMouseEnter Problem in C# Pin
Phoen2529-Mar-06 7:26
Phoen2529-Mar-06 7:26 
QuestionHelp! Asynchronous Executions Pin
swanmynova29-Mar-06 6:28
swanmynova29-Mar-06 6:28 
AnswerRe: Help! Asynchronous Executions Pin
Judah Gabriel Himango29-Mar-06 11:19
sponsorJudah Gabriel Himango29-Mar-06 11:19 
GeneralRe: Help! Asynchronous Executions Pin
swanmynova30-Mar-06 5:18
swanmynova30-Mar-06 5:18 
GeneralRe: Help! Asynchronous Executions Pin
Judah Gabriel Himango30-Mar-06 6:30
sponsorJudah Gabriel Himango30-Mar-06 6:30 
GeneralRe: Help! Asynchronous Executions Pin
swanmynova30-Mar-06 7:54
swanmynova30-Mar-06 7:54 
QuestionFLOPS Pin
Mridang Agarwalla29-Mar-06 5:58
Mridang Agarwalla29-Mar-06 5:58 
QuestionFlags problem Pin
Mridang Agarwalla29-Mar-06 5:53
Mridang Agarwalla29-Mar-06 5:53 
I'm having a slight problem with flags. I downloaded a small class from CP called Task Scheduler. It contains an enum called DaysOfTheWeek. This enumeration contains all the seven days of the week. This enumeration has the Flag option set to on and as i read somewhere, multiple flags can be passed at once by using the pipe operator (|). Now the class contains a function which takes the enumeration DaysOfTheWeek as a parameter. When I have to call the function, I can easily do so by writing

TestFunction(DaysOfTheWeek.Monday)

That was easy. Now, I have seven check boxes on my form called chkSunday, chkMonday....chkSaturday. Now, I have to call the function by passing the flags which in turn depend on the check boxes that are selected. For example, if the user has selected chkMonday and chkSunday, I would call the function like this

TestFunction(DaysOfTheWeek.Monday | DaysOfTheWeek.Sunday)

This is where the the problem lies. i can't possibly write a set of if else statements that take into account all the possible combinations of checkboxes being selected and appropriately calling the function. How do I do this?

I thought of this but it doesnt work:

<br />
TaskScheduler.DaysOfTheWeek enmDays;<br />
if (chkSunday.Checked == true)<br />
	enmDays = enmDays | DaysOfTheWeek.Sunday;<br />
if (chkMonday.Checked == true)<br />
	enmDays = enmDays | DaysOfTheWeek.Monday;<br />
if (chkTuesday.Checked == true)<br />
	enmDays = enmDays | DaysOfTheWeek.Tuesday;<br />
if (chkWednesday.Checked == true)<br />
	enmDays = enmDays | DaysOfTheWeek.Wednesday;<br />
if (chkThursday.Checked == true)<br />
	enmDays = enmDays | DaysOfTheWeek.Thursday;<br />
if (chkFriday.Checked == true)<br />
	enmDays = enmDays | DaysOfTheWeek.Friday;<br />
if (chkSaturday.Checked == true)<br />
	enmDays = enmDays | DaysOfTheWeek.Saturday;<br />
TestFunction(enmDays);<br />

GeneralRe: Flags problem Pin
Guffa29-Mar-06 6:52
Guffa29-Mar-06 6:52 
AnswerRe: Flags problem Pin
Ravi Bhavnani29-Mar-06 7:39
professionalRavi Bhavnani29-Mar-06 7:39 
GeneralRe: Flags problem Pin
Mridang Agarwalla29-Mar-06 15:17
Mridang Agarwalla29-Mar-06 15:17 
GeneralRe: Flags problem Pin
Ravi Bhavnani29-Mar-06 16:12
professionalRavi Bhavnani29-Mar-06 16:12 
AnswerRe: Flags problem Pin
darkelv29-Mar-06 16:10
darkelv29-Mar-06 16:10 
Questioncanny edge detection Pin
preci29-Mar-06 5:41
preci29-Mar-06 5:41 
AnswerRe: canny edge detection Pin
Ravi Bhavnani29-Mar-06 8:16
professionalRavi Bhavnani29-Mar-06 8:16 
GeneralRe: canny edge detection Pin
preci29-Mar-06 21:08
preci29-Mar-06 21:08 
GeneralRe: canny edge detection Pin
Ravi Bhavnani30-Mar-06 2:10
professionalRavi Bhavnani30-Mar-06 2:10 
GeneralRe: Thank you Ravi Pin
preci30-Mar-06 3:30
preci30-Mar-06 3:30 
QuestionGet computer name Pin
superdragon29-Mar-06 5:20
superdragon29-Mar-06 5:20 
AnswerRe: Get computer name Pin
superdragon29-Mar-06 5:50
superdragon29-Mar-06 5:50 
Questionchecking whether checkedlistbox .items[i] is selected? Pin
superdragon29-Mar-06 4:52
superdragon29-Mar-06 4:52 
AnswerRe: checking whether checkedlistbox .items[i] is selected? Pin
superdragon29-Mar-06 5:30
superdragon29-Mar-06 5:30 
QuestionProgram runs different on other computers Pin
TofuBug2429-Mar-06 4:48
TofuBug2429-Mar-06 4:48 
QuestionPocketPC + playsound Pin
hung_ngole29-Mar-06 3:47
hung_ngole29-Mar-06 3:47 
QuestionRetrieve shortcut(.lnk) target location Pin
boshesh29-Mar-06 3:30
boshesh29-Mar-06 3:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.