samedi 27 août 2016

get checked checkBoxes texts in C#

I have 4 checkBox in my windows form application and I need to get the text of checked checkBox by returning it from a string function but it gives me an exception. The codes of the function are:

 string getPerm()
{
   string perm = "";
   foreach(CheckBox chkb in this.Controls)
   {
       if(chkb.Checked==true)
   {
   perm += chkb.Text + ",";
   }
     return perm;
   }

And I used this function in Show method of messageBox to show the result on click event of a button , one more problem is that I need to delete the last comma from the result... regards




Aucun commentaire:

Enregistrer un commentaire