C# monthCalendar

这个控件是不能改大小的,只能通过改变字体大小来控制!

CurrentCulture

CurrentCulture 属性表示每个线程的当前区域性信息。 此信息确定了日期、时间、货币和数字的默认格式,文本的排序顺序,字符串比较方式以及大小写。 通过此属性进行的设置不是语言设置。 此属性仅定义与地理区域的标准设置相关的数据。 因此,应用程序只能将 CurrentCulture 设置为特定区域性或设置为 InvariantCulture 应用程序可以使用 CurrentThread 属性来设置 CurrentCulture

更改 CurrentThread 的区域性需要使用设置了 ControlThreadSecurityPermission 由于安全状态与线程关联,对线程进行操作是危险的。 因此,应只向可信代码授予该权限,并且只在必要的时候才授予该权限。 不能在不完全受信任的代码中更改线程区域性。

下面的代码示例将该属性设置为特定区域性德语(德国),即“de-DE”。

Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
在 .aspx 页中显式设置 CurrentCulture 属性

CreateSpecificCulture 方法还允许应用程序使用 Web 浏览器的当前语言来初始化 .aspx 页面中的 CurrentCulture 属性。 在下面的代码示例中,UserLanguages 属性以字符串形式检索 Web 浏览器的当前语言。 CreateSpecificCulture 方法分析此字符串,并以可用于初始化 CurrentCulture 属性值的格式返回一个 CultureInfo 对象。

Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages[0]);
隐式设置 CurrentCulture 属性

在 Windows 操作系统中,GetUserDefaultLCID 函数用于设置 CurrentCulture 属性。 用户可以通过在“控制面板”的“区域和语言选项”中更改用户区域性,或者通过更改与用户区域设置相关的设置(如货币、数字、日期和时间格式),更改此属性。

如果要确保应用程序使用 .NET Framework 为指定区域性提供的默认货币、数字、日期和时间格式,请让应用程序重写用户区域设置的默认值。 应用程序应使用接受 useUserOverride 参数的构造函数重载来创建 CultureInfo 对象,并将此参数设置为 false 使用此技术会导致用户操作系统上的默认设置被 .NET Framework 的默认设置重写。 为使用欧元进行交易的欧盟 (EU) 成员格式化货币时,建议应用程序将 useUserOverride 参数设置为 false,以确保使用正确的货币符号。 有关更多信息,请参见 针对特定区域性格式化数值型数据 主题中的“设置欧元格式”子主题。


转载于:https://www.cnblogs.com/genghechuang/archive/2011/10/28/2227823.html

制作一个简易的万年历 string intmonth = monthCalendar1.TodayDate.Month.ToString(); string intday = monthCalendar1.TodayDate.Day.ToString(); if (monthCalendar1.TodayDate.Month < 10) { intmonth = &quot;0&quot; + monthCalendar1.TodayDate.Month.ToString(); } if (monthCalendar1.TodayDate.Day < 10) { intday = &quot;0&quot; + monthCalendar1.TodayDate.Day.ToString(); } string s = String.Format(&quot;{0}年{1}月{2}&quot;, GetStemBranch(monthCalendar1.TodayDate), GetMonth(monthCalendar1.TodayDate), GetDay(monthCalendar1.TodayDate)); label1.Text = monthCalendar1.TodayDate + &quot;年&quot; + intmonth + &quot;月&quot; + intday + &quot;日&quot; + &quot; &quot; + s + &quot; &quot; + getReturnYear(monthCalendar1.TodayDate)+&quot;年&quot;; label1.ForeColor = Color.Green; } public string GetStemBranch(DateTime time) { string TerrestrialBranch = &quot;子丑寅卯辰巳午未申酉戌亥&quot;; string CelestialStem = &quot;甲乙丙丁戊己庚辛壬癸&quot;; int sexagenaryYear = cc.GetSexagenaryYear(time);//计算与指定日期对应的甲子(60年)循环中的年,此方法返回甲子循环中的一个从1到60的数字,它与date参数对应 string stemBranch = CelestialStem.Substring(cc.GetCelestialStem(sexagenaryYear) - 1, 1) + TerrestrialBranch.Substring(cc.GetTerrestrialBranch(sexagenaryYear) - 1, 1);//substring() 方法返回的子串包括 start 处的字符,但不包括 stop 处的字符 return stemBranch; } public string GetMonth(DateTime time) { string[] ChineseMonthName = new string[] { &quot;正&quot;, &quot;二&quot;, &quot;三&quot;, &quot;四&quot;, &quot;五&quot;, &quot;六&quot;, &quot;七&quot;, &quot;八&quot;, &quot;九&quot;, &quot;十&quot;, &quot;十一&quot;, &quot;十二&quot; }; int month =cc.GetMonth(time);//获取当前日期的月份 int year = cc.GetYear(time);//获取当前日期的年份 int leap = 0; for (int i = 3; i <= month; i++) { if (cc.IsLeapMonth(year,i))//判断是否是闰年 { leap = i;//一年中最多有一个闰月 break; } } if (leap > 0) month--; return (leap == month + 1 ? &quot;闰&quot; : &quot;&quot;) +ChineseMonthName[month - 1];//返回农历月份
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值