代码
 private void bindCBSessionTimeOut()
        {
            IList
<DictionaryEntry> List = new List<DictionaryEntry>();
            List.Add(
new DictionaryEntry("30 mins", TimeSpan.FromMinutes(30)));
            List.Add(
new DictionaryEntry("1 hours", TimeSpan.FromHours(1)));
            List.Add(
new DictionaryEntry("2 hours", TimeSpan.FromHours(2)));
            List.Add(
new DictionaryEntry("3 hours", TimeSpan.FromHours(3)));
            List.Add(
new DictionaryEntry("4 hours", TimeSpan.FromHours(4)));
            
try
            {
                cbSessionTimeOut.DataSource 
= List;
                cbSessionTimeOut.DisplayMember 
= "Key";
                cbSessionTimeOut.ValueMember 
= "Value";
            }
            
catch (Exception ce)
            {

                Console.WriteLine(ce.ToString()); ;
            }
        }

代码片段,关键:List添加的是要多个DictionaryEntry

相关文章:

  • 2021-11-21
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2022-02-27
猜你喜欢
  • 2022-12-23
  • 2022-01-27
  • 2021-06-21
  • 2022-03-06
  • 2021-10-31
  • 2021-08-14
  • 2022-02-26
相关资源
相似解决方案