本文介绍了多语言C#桌面应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在c#桌面应用程序中更改动态创建控件的语言。
例如 - 在我的应用程序中,我必须动态创建大量按钮。我可以更改预定义控件的语言,但如何更改无限动态按钮的语言。
How can i change language for dynamically create controls in c# desktop application.
For example - in my application i have to create lot of buttons dynamically. I can change language for predefined controls but how to change language for unlimited dynamic button.
推荐答案
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Culture="auto" meta:resourcekey="PageResource1" UICulture="auto" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblWelcome" runat="server" meta:resourcekey="lblWelcomeResource1"
Text="Welcome to Learning"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
<asp:ListItem Value="en-us">English</asp:ListItem>
<asp:ListItem Value="hi-in">हिंदी</asp:ListItem>
</asp:DropDownList><br />
<br />
<asp:Label ID="lblNotice" runat="server" meta:resourcekey="lblNoticeResource1" Text="Today is:"></asp:Label>
<asp:Label ID="lblTime" runat="server" meta:resourcekey="lblTimeResource1"></asp:Label></div>
</form>
</body>
</html>
Default.aspx.cs
"Default.aspx.cs"
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lblTime.Text = DateTime.Now.ToShortDateString();
}
protected override void InitializeCulture()
{
if (Request.Form["DropDownList1"] != null)
{
UICulture = Request.Form["DropDownList1"];
Culture = Request.Form["DropDownList1"];
}
base.InitializeCulture();
}
}
这篇关于多语言C#桌面应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!