C implements the method of returning the information of the selected check box to the user

  • 2021-07-01 08:06:54
  • OfStack

This article illustrates how the C # implementation returns the information of the selected check box to the user. Share it for your reference. The specific implementation method is as follows:


/// <summary>
///  Custom method to get the value selected in the check box, separated by the specified separator 
/// </summary>
/// <param name="split"> Separator </param>
/// <param name="chk"> Checkbox name </param>
/// <returns> Returns the value selected in the check box </returns>
string GetCheckBoxItems(string split, params CheckBox[] chk)
{
string items = string.Empty;
for (int i = 0; i < chk.Length; i++)
{// Will each 1 The text and delimiter of the selected check boxes are added to the string 
if (chk[i].Checked)
{
items += chk[i].Text + split;
}
}
if (!string.IsNullOrEmpty(items))
{// If a string is selected, the last 1 The separator is removed 
items = items.Substring(0, items.Length - 1);
}
return items;
}

I hope this article is helpful to everyone's C # programming.


Related articles: