#region ComboBox Items设定
/// <summary>
/// ComboBox Items设定
/// </summary>
/// <param name="CobBox">ComboBox 名称</param>
/// <param name="ItemsValue">要添加的Items(各项目之间用;隔开)</param>
public static void SetCobBoxItems(ComboBox CobBox, string ItemsValue)
{
CobBox.Items.Clear();
CobBox.Text = "";
if (ItemsValue == null) { return; }
string[] s = ItemsValue.Split(new char[] { ';' });
for (int i = 0; i <= s.Length - 1; i++)
{
CobBox.Items.Add(s[i].ToString());
}
}
/// <summary>
/// ComboBox Items设定
/// </summary>
/// <param name="CobBox">ComboBox 名称</param>
/// <param name="ItemsList">List</param>
public static void SetCobBoxItems(ComboBox CobBox, List<string> ItemsList)
{
CobBox.Items.Clear();
CobBox.Text = "";
if (ItemsList.Count == 0) { return; }
for (int i = 0; i <= ItemsList.Count-1;i++ )
{
CobBox.Items.Add(ItemsList[i].ToString());
}
}
#endregion
C#动态设置combox控件的Items属性
最新推荐文章于 2024-11-07 08:51:26 发布