Click here to Skip to main content
15,921,646 members
Home / Discussions / C#
   

C#

 
GeneralRe: Question on iterators Pin
Dewald14-Jun-07 1:28
Dewald14-Jun-07 1:28 
GeneralRe: Question on iterators Pin
Colin Angus Mackay14-Jun-07 2:04
Colin Angus Mackay14-Jun-07 2:04 
GeneralRe: Question on iterators Pin
Dewald14-Jun-07 2:21
Dewald14-Jun-07 2:21 
AnswerRe: Question on iterators Pin
Luc Pattyn14-Jun-07 1:27
sitebuilderLuc Pattyn14-Jun-07 1:27 
GeneralRe: Question on iterators Pin
Dewald14-Jun-07 2:02
Dewald14-Jun-07 2:02 
GeneralRe: Question on iterators Pin
Luc Pattyn14-Jun-07 2:19
sitebuilderLuc Pattyn14-Jun-07 2:19 
GeneralRe: Question on iterators Pin
Le centriste14-Jun-07 7:24
Le centriste14-Jun-07 7:24 
QuestionStruggling with delegates Pin
kbalias14-Jun-07 0:10
kbalias14-Jun-07 0:10 
Hi
I am struggling with delegates. I am using Visual Studio 2005 and C# to develop a windows application. I have a UserControl that allows the user to input data. At run-time I instantiate UserControls and add them to the windows form. Each UserControl has a checkbox that allow the user to select a UserControl for deletion.

At the moment when I delete I loop through all the UserControls and if the checkbox is checked then I remove it. There can be many UserControls on my form (I have tested it with 100 UserControls on the form) and to first loop through all the UserControls to determine which ones are checked takes up quite a bit of time.

I thought I can perhaps use delegates and events.
I would like to have a method in my form that add a UserControl to an ArrayList or remove it from the ArrayList depending on whether the checkbox on the UserControl is checked or not.

private ArrayList selectList = null;<br />
<br />
public delegate void CheckSelectionDelegate(UserControl1 u);<br />
<br />
public void CheckSelection(UserControl1 uc1)<br />
{<br />
//this is not the full code in this method yet<br />
    if (uc1.ChkBox.Checked == true)<br />
    {<br />
        selectList.Add(uc1);<br />
    }<br />
    else<br />
    {<br />
        selectList.Remove(uc1);<br />
    }<br />
}


On my UserControl whenever the CheckedChanged event fires on the checkbox I would like the UserControl to call the CheckSelection() method.

This way when I delete the program just has to loop through the selectList ArrayList and process them.

However I cannot find clear examples how to do something like this.

If anybody can help me or point me in the right direction, it will help me a lot.

Thanks.

Kobus
AnswerRe: Struggling with delegates Pin
Martin#14-Jun-07 1:29
Martin#14-Jun-07 1:29 
GeneralRe: Struggling with delegates Pin
kbalias14-Jun-07 18:51
kbalias14-Jun-07 18:51 
AnswerRe: Struggling with delegates Pin
Martin#14-Jun-07 19:29
Martin#14-Jun-07 19:29 
QuestionHow to read Character from Image Pin
Soosai13-Jun-07 23:59
Soosai13-Jun-07 23:59 
AnswerRe: How to read Character from Image Pin
Russell'14-Jun-07 1:52
Russell'14-Jun-07 1:52 
Questionturn a string into a querystring Pin
tim_gunning13-Jun-07 23:47
tim_gunning13-Jun-07 23:47 
Questioninclude icon to setup project Pin
korsosjosi13-Jun-07 23:20
korsosjosi13-Jun-07 23:20 
AnswerRe: include icon to setup project Pin
Colin Angus Mackay13-Jun-07 23:26
Colin Angus Mackay13-Jun-07 23:26 
GeneralRe: include icon to setup project Pin
korsosjosi13-Jun-07 23:42
korsosjosi13-Jun-07 23:42 
GeneralRe: include icon to setup project Pin
Colin Angus Mackay13-Jun-07 23:46
Colin Angus Mackay13-Jun-07 23:46 
GeneralRe: include icon to setup project Pin
korsosjosi13-Jun-07 23:47
korsosjosi13-Jun-07 23:47 
AnswerRe: include icon to setup project Pin
Hesham Yassin14-Jun-07 8:23
Hesham Yassin14-Jun-07 8:23 
QuestionAccessing Active Directory profile "on the fly" Pin
Klaus MJ13-Jun-07 22:47
Klaus MJ13-Jun-07 22:47 
QuestionSearching for an alternative of typedef in C# [modified] Pin
Gatchan13-Jun-07 22:43
Gatchan13-Jun-07 22:43 
AnswerRe: Searching for an alternative of typedef in C# [modified] Pin
Luc Pattyn14-Jun-07 0:58
sitebuilderLuc Pattyn14-Jun-07 0:58 
GeneralRe: Searching for an alternative of typedef in C# Pin
Gatchan14-Jun-07 2:22
Gatchan14-Jun-07 2:22 
GeneralRe: Searching for an alternative of typedef in C# Pin
Luc Pattyn14-Jun-07 2:31
sitebuilderLuc Pattyn14-Jun-07 2:31 

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.