如何使用所有时区填充下拉列表 [英] How to fill the dropdown with all timezone

查看:108
本文介绍了如何使用所有时区填充下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对时区有疑问,我想用世界上所有时区填写下拉列表,当我选择其中一个时我想保存该下拉列表的选定值,为此我使用代码

 ReadOnlyCollection< TimeZoneInfo>的TimeZoneInfo; 
timezoneInfo = TimeZoneInfo.GetSystemTimeZones();
strTimezone = string .Join( ; 来自时间 timezoneInfo
选择 string .Format( {0}:{1}
Time.Id,Time.DisplayName));



但借助我的下拉列表是只有一个时区chennai kolkatta,因为我的系统只有一个时区chennai kolkatta,下拉列表只包含一个值,但我想要所有的时区,我想做的请尽早帮助我。

解决方案

将下拉列表的数据源设置为集合...

 this.comboBox1.DataSource = timezoneInfo; 


请参阅 -

http://stackoverflow.com/questions/6372566/get-time-zones-list-in-c-sharp [< a href =http://stackoverflow.com/questions/6372566/get-time-zones-list-in-c-sharptarget =_ blanktitle =New Window> ^ ]

I have question about timezone, i want to fill the dropdown with all timezone in world and when i select one of them i want to save the selected value of that dropdown, for that i use the code

ReadOnlyCollection<TimeZoneInfo> timezoneInfo;
timezoneInfo = TimeZoneInfo.GetSystemTimeZones();
strTimezone = string.Join(";", from Time in timezoneInfo
select string.Format("{0}:{1}",
Time.Id, Time.DisplayName));


but with the help of that my dropdown is fill with only one timezone which is chennai kolkatta because my system has only one timezone which is chennai kolkatta that dropdown contain only one value, but i want all timezone for that what i do please help me as early as possible.

解决方案

Set the datasource of your dropdown to the collection ...

this.comboBox1.DataSource = timezoneInfo;


Refer this-
http://stackoverflow.com/questions/6372566/get-time-zones-list-in-c-sharp[^]


这篇关于如何使用所有时区填充下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆