winform页面click事件:
private void button1_Click(object sender, EventArgs e)
{
button1.Text = StringConvert("陳", "t2s");
}
/// 简体和繁体互转
/// </summary>
/// <param name="x"></param>
/// <param name="type">s2t|t2s</param>
/// <returns></returns>
public static string StringConvert(string str, string type)
{
String value = String.Empty;
switch (type)
{
case "s2t"://转繁体
value = Microsoft.VisualBasic.Strings.StrConv(str, Microsoft.VisualBasic.VbStrConv.TraditionalChinese, 0);
break;
case "t2s"://转简体
value = Microsoft.VisualBasic.Strings.StrConv(str, Microsoft.VisualBasic.VbStrConv.SimplifiedChinese, 0);
break;
default:
value = str;
break;
}
return value;
private void button1_Click(object sender, EventArgs e)
{
button1.Text = StringConvert("陳", "t2s");
}
/// 简体和繁体互转
/// </summary>
/// <param name="x"></param>
/// <param name="type">s2t|t2s</param>
/// <returns></returns>
public static string StringConvert(string str, string type)
{
String value = String.Empty;
switch (type)
{
case "s2t"://转繁体
value = Microsoft.VisualBasic.Strings.StrConv(str, Microsoft.VisualBasic.VbStrConv.TraditionalChinese, 0);
break;
case "t2s"://转简体
value = Microsoft.VisualBasic.Strings.StrConv(str, Microsoft.VisualBasic.VbStrConv.SimplifiedChinese, 0);
break;
default:
value = str;
break;
}
return value;
}
//繁体转简体
pis = ent.GetType().GetProperties(); //获得所有的页面控件的类型属性
foreach (PropertyInfo pi in pis) //遍历更改控件内容
{
val = pi.GetValue(ent, null) + "";
if (pi.Name != "ID" && val != "" && pi.CanWrite && pi.PropertyType == typeof(string))
{
pi.SetValue(ent, WFHelper.StringConvert(val, "t2s"), null); //设置控件内容
}
}