469,331 Members | 4,161 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,331 developers. It's quick & easy.

Checkbox array question (Program stops responding)

4
I need to associate the elements of a bool type matrix with the state of a checkbox from an array that i've created. For example: if the element checkBoxMatrix[3,4] is checked then the the element in boolMatrix[3,4] is changed to true and if it is unchecked it is changed to false. However; this is not my problem.

The size of the matrices aren't fixed. I dynamically allocate the number of rows and columns.It works fine when the ranges are small, but when these ranges become kind of big, for example 100 by 100, the program stops responding.

I would like to stick with the array of checkboxes since I'm kind of new with C#, but creating a table (like in Exel, if there is a way) on the form would suffice.

Any and all ideas are welcome...
Dec 6 '07 #1
3 1424
Frinavale
9,735 Expert Mod 8TB
I need to associate the elements of a bool type matrix with the state of a checkbox from an array that i've created. For example: if the element checkBoxMatrix[3,4] is checked then the the element in boolMatrix[3,4] is changed to true and if it is unchecked it is changed to false. However; this is not my problem.

The size of the matrices aren't fixed. I dynamically allocate the number of rows and columns.It works fine when the ranges are small, but when these ranges become kind of big, for example 100 by 100, the program stops responding.

I would like to stick with the array of checkboxes since I'm kind of new with C#, but creating a table (like in Exel, if there is a way) on the form would suffice.

Any and all ideas are welcome...
Could you please post the code that you are using to dynamically allocate the memory for your arrays?

Are you sure that you are properly cleaning up the memory once you are finished with it?

(Is this a web application or desktop application?)
Dec 6 '07 #2
Jakes
4
****This is the code where I create the array:
Expand|Select|Wrap|Line Numbers
  1. this.ActCondState=new System.Windows.Forms.CheckBox[this.ruleType.GetNumOfRules(),this.ruleType.GetNumOfAct() + this.ruleType.GetNumOfCond()];
  2.  
  3. j=40;
  4.  
  5. this.checkBoxDimension1 = this.ruleType.GetNumOfRules();
  6. this.checkBoxDimension2 = this.ruleType.GetNumOfAct() + this.ruleType.GetNumOfCond();
  7.  
  8. //Creates the checkboxes which maintain the state of each entry in the decision matrix
  9. for(k=0;k<this.checkBoxDimension1;++k)
  10. {
  11.      int o=30;
  12.      for(l=0;l<this.checkBoxDimension2;++l)
  13.      {
  14.         this.ActCondState[k,l] = new System.Windows.Forms.CheckBox();
  15.         if(this.ruleType.GetDecisionMatrixElem(k,l) == true)
  16.     this.ActCondState[k,l].Checked =true;
  17.         this.ActCondState[k,l].CheckStateChanged += new EventHandler
  18.         mainFrm_CheckStateChanged);
  19.         this.ActCondState[k,l].Location = new System.Drawing.Point(j,o);
  20.         this.ActCondState[k,l].Size =new System.Drawing.Size(30,20);
  21.         this.ActCondState[k,l].Name = "ActCondState"+k+"_"+l; 
  22.         this.RuleTypePopulateTab.Controls.AddRange(new
  23.         System.Windows.Forms.Control[]  {this.ActCondState[k,l]});
  24.         o+=20;
  25.       }
  26.       j+=40;
  27. }
  28.  
  29. //****This is the code where i dispose of each individual checkbox:
  30.  
  31. if(ActCondState != null)
  32. {
  33.           for(k=0;k<this.checkBoxDimension1;++k)
  34.     for(l=0;l<this.checkBoxDimension2;++l)
  35.     {
  36.           this.ActCondState[k,l].Dispose();
  37.     }
  38. }
  39.  
Thank you for your response
Dec 7 '07 #3
Jakes
4
Oh, and its a desktop application.
Dec 7 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by claudel | last post: by
4 posts views Thread by Piotr | last post: by
10 posts views Thread by Nimit | last post: by
9 posts views Thread by Craig Andrews | last post: by
1 post views Thread by Sluggoman | last post: by
8 posts views Thread by Sunny | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.