本文整理汇总了C#中System.Windows.Forms.UserControl.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# UserControl.GetType方法的具体用法?C# UserControl.GetType怎么用?C# UserControl.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.UserControl
的用法示例。
在下文中一共展示了UserControl.GetType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowMaintain
public void ShowMaintain(UserControl maintainPanel)
{
var onList = false;
for (var i = 0; i < splitContainerCenter.Panel2.Controls.Count; i++)
{
splitContainerCenter.Panel2.Controls.RemoveAt(i);
}
foreach (var a in ListActiveObject.Where(a => a.Name.Equals(maintainPanel.GetType().ToString()) && a.Index == ((MaintainBaseControl)maintainPanel).Index))
{
onList = true;
splitContainerCenter.Panel2.Controls.Add(a.MaintainObject);
maintainPanel.Dock = DockStyle.Fill;
break;
}
if (onList) return;
splitContainerCenter.Panel2.Controls.Add(maintainPanel);
//((MaintainBaseControl)maintainPanel).FormParameter = formParameter;
((MaintainBaseControl)maintainPanel).MainConfiguration = this;
maintainPanel.Dock = DockStyle.Fill;
ListActiveObject.Add(new ActiveObject
{
Name = maintainPanel.GetType().ToString(),
//ListParameterForm = formParameter,
MaintainObject = maintainPanel,
Index = ((MaintainBaseControl)maintainPanel).Index
});
}
示例2: LoadControlAndResize
/// <summary>
/// Loads the control and resize.
/// </summary>
/// <param name="container">The container.</param>
/// <param name="control">The control.</param>
/// <param name="height">The height.</param>
/// <param name="width">The width.</param>
public static void LoadControlAndResize(Control container, UserControl control, int height, int width)
{
if (control == null && container == null)
{
throw new ArgumentNullException(GenericConstants.LOAD_CONTROL_AND_RESIZE_PARAMETER_IS_NULL);
}
if (control.GetType().GetInterface("IResizableControl") != null)
((IResizableControl)control).ResizeControl(height, width);
container.Controls.Clear();
container.Controls.Add(control);
}
示例3: SetToolbar
/// <summary>
/// 设置工具栏权限
/// </summary>
/// <param name="control">注册模块的用户对象</param>
/// <param name="barmanager">工具栏的管理对象</param>
public static void SetToolbar(UserControl control,BarManager barmanager) {
if ((control.Site == null) && (barmanager != null)) {
List<string> userFunction = UserFunctions;
if ((control != null) && (userFunction != null)) {
IList btNames = BtNamesList;
string fullName = control.GetType().FullName;
foreach (BarItem item in barmanager.Items) {
if (userFunction.Contains(fullName + "_" + item.Name)) {
item.Enabled = true;
} else if (btNames.Contains(item.Name)) {
item.Enabled = false;
}
}
}
}
}
示例4: SetLanguageResource
public static int SetLanguageResource(UserControl userControl)
{
int returnValue = 0;
string key = string.Empty;
string language = string.Empty;
System.Reflection.FieldInfo[] fieldInfo = userControl.GetType().GetFields(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
for (int i = 0; i < fieldInfo.Length; i++)
{
if ((fieldInfo[i].FieldType.Name.Equals("Label")) || (fieldInfo[i].FieldType.Name.Equals("CheckBox")) || (fieldInfo[i].FieldType.Name.Equals("Button")) || (fieldInfo[i].FieldType.Name.Equals("GroupBox")) || (fieldInfo[i].FieldType.Name.Equals("RadioButton")))
{
Control control = (Control)fieldInfo[i].GetValue(userControl);
// 窗体上的控件多语言处理
key = userControl.GetType().Name + "_" + control.Name;
language = ResourceManagerWrapper.Instance.Get(key);
if (language.Length > 0)
{
control.Text = language;
returnValue++;
}
}
// 对表格的列名多语言处理
if (fieldInfo[i].FieldType.Name.Equals("DataGridView"))
{
DataGridView targetDataGridView = (DataGridView)fieldInfo[i].GetValue(userControl);
for (int j = 0; j < targetDataGridView.ColumnCount; j++)
{
key = userControl.Name + "_" + targetDataGridView.Columns[j].Name;
language = ResourceManagerWrapper.Instance.Get(key);
if (language.Length > 0)
{
targetDataGridView.Columns[j].HeaderText = language;
returnValue++;
}
}
}
}
return returnValue;
}
示例5: SetLanguage
/// <summary>
/// Thiết lập ngôn ngữ hiển thị cho một Form chức năng
/// </summary>
/// <param name="Language">Mã ngôn ngữ truyền vào thường là biến gv_sLanguageDisplay</param>
/// <param name="ctrMain">Tên Control(Form) sẽ bị tác động. Giá trị thường là 'me' trong VB.NET hoặc 'this' trong C#</param>
/// <param name="sDLLName">Tên DLL chứa Form chức năng(Ví dụ: Invoice.Dll)</param>
/// <param name="gv_oSqlCnn">Biến kết nối tới CSDL. Thường sử dụng luôn biến gv_oSqlCnn</param>
/// <remarks></remarks>
public static void SetLanguage(string Language, Control ctrMain, string sDLLName, System.Data.SqlClient.SqlConnection gv_oSqlCnn)
{
SqlDataAdapter da1 = new SqlDataAdapter("SELECT * FROM Sys_MULTILANGUAGE WHERE sFormName=N'" + ctrMain.Name + "' AND sDLLName=N'" + sDLLName + "'", globalVariables.SqlConn);
DataTable DT1 = new DataTable();
string sVnText = null;
string sEnText = null;
sVnText = "";
sEnText = "";
try
{
da1.Fill(DT1);
if (DT1.Rows.Count > 0)
{
foreach (DataRow dr1 in DT1.Rows)
{
if (!Information.IsDBNull(dr1["sVnText"]) & string.IsNullOrEmpty(sVnText))
{
sVnText = Utility.sDbnull(dr1["sVnText"]);
}
if (!Information.IsDBNull(dr1["sEnText"]))
{
sEnText = Utility.sDbnull(dr1["sEnText"]);
}
if (!string.IsNullOrEmpty(sVnText) & !string.IsNullOrEmpty(sEnText))
{
break; // TODO: might not be correct. Was : Exit For
}
}
if (Language.ToUpper() == "VN")
{
ctrMain.Text = sVnText;
}
else
{
ctrMain.Text = sEnText;
}
UserControl UC = new UserControl();
foreach (Control ctr in ctrMain.Controls)
{
if ((ctr) is TextBox || (ctr) is UserControl || (ctr) is Label | (ctr) is Button | (ctr) is GroupBox | (ctr) is CheckBox | (ctr) is RadioButton | (ctr) is Panel | (ctr) is ComboBox)
{
string CtrlName = null;
if ((ctr.Parent != null) && ctr.Parent.GetType().BaseType.FullName == UC.GetType().FullName)
{
CtrlName = ctr.Parent.Name + "." + ctr.Name;
}
else
{
CtrlName = ctr.Name;
}
DataRow[] dr = null;
dr = DT1.Select("sFormName='" + ctrMain.Name + "' AND sControlName='" + CtrlName + "'");
if (dr.GetLength(0) > 0)
{
if (Language.ToUpper() == "VN")
{
if ((ctr) is ComboBox)
{
ComboBox cbo = null;
string[] splt = Utility.sDbnull(dr[0]["sVn"]).Split( ',');
cbo = (ComboBox)ctr;
cbo.Items.Clear();
for (int i = 0; i <= splt.GetLength(0) - 1; i++)
{
cbo.Items.Add(splt[i]);
}
}
else
{
ctr.Text = Utility.sDbnull(dr[0]["sVn"]);
}
}
else
{
if ((ctr) is ComboBox)
{
ComboBox cbo = null;
string[] splt = Utility.sDbnull(dr[0]["sEn"]).Split( ',');
cbo = (ComboBox)ctr;
cbo.Items.Clear();
for (int i = 0; i <= splt.GetLength(0) - 1; i++)
{
cbo.Items.Add(splt[i]);
}
}
else
{
ctr.Text = Utility.sDbnull(dr[0]["sEn"]);
}
}
}
else
//.........这里部分代码省略.........
示例6: LoopControl
private static void LoopControl(Control mainForm, DataTable dt1, Control objCtr, string pv_sLang)
{
UserControl UC = new UserControl();
foreach (Control ctr in objCtr.Controls)
{
if ((ctr) is TextBox || (ctr) is UserControl || (ctr) is Label | (ctr) is Button | (ctr) is GroupBox | (ctr) is CheckBox | (ctr) is RadioButton | (ctr) is Panel | (ctr) is ComboBox)
{
DataRow[] dr = null;
string CtrlName = null;
if ((ctr.Parent != null) && ctr.Parent.GetType().BaseType.FullName == UC.GetType().FullName)
{
CtrlName = ctr.Parent.Name + "." + ctr.Name;
}
else
{
CtrlName = ctr.Name;
}
dr = dt1.Select("sFormName='" + mainForm.Name + "' AND sControlName='" + CtrlName + "'");
if (dr.GetLength(0) > 0)
{
if (pv_sLang.ToUpper() == "VN")
{
if ((ctr) is ComboBox)
{
ComboBox cbo = null;
string[] splt = Utility.sDbnull(dr[0]["sVn"]).Split( ',');
cbo = (ComboBox)ctr;
cbo.Items.Clear();
for (int i = 0; i <= splt.GetLength(0) - 1; i++)
{
cbo.Items.Add(splt[i]);
}
}
else
{
ctr.Text = Utility.sDbnull(dr[0]["sVn"]);
}
}
else
{
if ((ctr) is ComboBox)
{
ComboBox cbo = null;
string[] splt = Utility.sDbnull(dr[0]["sEn"]).Split( ',');
cbo = (ComboBox)ctr;
cbo.Items.Clear();
for (int i = 0; i <= splt.GetLength(0) - 1; i++)
{
cbo.Items.Add(splt[i]);
}
}
else
{
ctr.Text = Utility.sDbnull(dr[0]["sEn"]);
}
}
}
else
{
}
LoopControl(mainForm, dt1, ctr, pv_sLang);
}
else if ((ctr) is StatusStrip)
{
}
else if ((ctr) is ToolStrip)
{
}
else if ((ctr) is DataGridView)
{
objGetCurrentDataGridView((Form)mainForm, ctr.Name);
// CType(ctr, DataGridView)
foreach (DataGridViewColumn col in CurrDtGridView.Columns)
{
DataRow[] dr = null;
dr = dt1.Select("sFormName='" + mainForm.Name + "' AND sControlName='" + col.Name + "'");
if (dr.GetLength(0) > 0)
{
if (pv_sLang.ToUpper() == "VN")
{
col.HeaderText = Utility.sDbnull(dr[0]["sVn"]);
}
else
{
col.HeaderText = Utility.sDbnull(dr[0]["sEn"]);
}
}
else
{
}
}
LoopControl(mainForm, dt1, ctr, pv_sLang);
}
}
}
示例7: LoopControl
//private static void objGetCurrentUITab(Control objMain, string pv_sName)
//{
// foreach (Control ctr in objMain.Controls)
// {
// if (ctr.Name == pv_sName)
// {
// CurrUITab = (Janus.Windows.UI.Tab.UITab)ctr;
// }
// else
// {
// objGetCurrentUITab(ctr, pv_sName);
// }
// }
//}
private static void LoopControl(Control mainForm, DataTable dt1, Control objCtr, string pv_sLang)
{
UserControl UC = new UserControl();
foreach (Control ctr in objCtr.Controls)
{
//if (ctr is Janus.Windows.UI.Tab.UITab || ctr is Janus.Windows.UI.Tab.UITabPage || ctr is TabControl || ctr is TabPage || ctr is StatusStrip || ctr is UserControl || ctr is ToolStrip || ctr is Label || ctr is Button || ctr is GroupBox || ctr is CheckBox || ctr is RadioButton || ctr is Panel || ctr is ComboBox || ctr is TextBox)
if ( ctr is TabControl || ctr is TabPage || ctr is StatusStrip || ctr is UserControl || ctr is ToolStrip || ctr is Label || ctr is Button || ctr is GroupBox || ctr is CheckBox || ctr is RadioButton || ctr is Panel || ctr is ComboBox || ctr is TextBox)
{
DataRow[] dr = null;
string CtrlName = ctr.Name;
if (CtrlName.Contains("Panel5"))
{
int i = 0;
}
if (ctr is Label)
{
if (ctr.Parent != null && ctr.Parent.GetType().BaseType.FullName == UC.GetType().FullName)
{
}
else
{
CtrlName = ctr.Parent.Name + "." + ctr.Name;
}
}
dr = dt1.Select("sFormName='" + mainForm.Name + "' AND sControlName='" + CtrlName + "'");
if (dr.GetLength(0) > 0)
{
if (pv_sLang.ToUpper() == "VN")
{
if (ctr is ComboBox)
{
ComboBox cbo = null;
string[] splt = sDBnull(dr[0]["sVn"], "").Split(',');
cbo = (ComboBox)ctr;
cbo.Items.Clear();
for (int i = 0; i <= splt.GetLength(0) - 1; i++)
{
cbo.Items.Add(splt[i]);
}
}
else
{
if (sDBnull(dr[0]["TTT"], "").ToString() == "1")
{
TTT.SetToolTip(ctr, sDBnull(dr[0]["sVn"], ""));
}
else
if (sDBnull(dr[0]["LCHK"], "").ToString() == "1")
ctr.Text = " " + sDBnull(dr[0]["sVn"], "");
else
ctr.Text = sDBnull(dr[0]["sVn"], "");
}
}
else
{
if (ctr is ComboBox)
{
ComboBox cbo = null;
string[] splt = sDBnull(dr[0]["sEn"], "").Split(',');
cbo = (ComboBox)ctr;
cbo.Items.Clear();
for (int i = 0; i <= splt.GetLength(0) - 1; i++)
{
cbo.Items.Add(splt[i]);
}
}
else
{
if (sDBnull(dr[0]["TTT"], "").ToString() == "1")
{
TTT.SetToolTip(ctr, sDBnull(dr[0]["sEn"], ""));
}
else
if (sDBnull(dr[0]["LCHK"], "").ToString() == "1")
ctr.Text = " " + sDBnull(dr[0]["sEn"], "");
else
ctr.Text = sDBnull(dr[0]["sEn"], "");
}
}
}
else
//.........这里部分代码省略.........
示例8: SetLanguage
//.........这里部分代码省略.........
//SetLanguageJanus(Language, ctrMain, DT1);
foreach (DataRow dr1 in DT1.Rows)
{
if (!DBNull.Value.Equals(dr1["sVnText"]) & string.IsNullOrEmpty(sVnText))
{
sVnText = sDBnull(dr1["sVnText"], "");
}
if (!DBNull.Value.Equals(dr1["sEnText"]))
{
sEnText = sDBnull(dr1["sEnText"], "");
}
if (!string.IsNullOrEmpty(sVnText) & !string.IsNullOrEmpty(sEnText))
{
break; // TODO: might not be correct. Was : Exit For
}
}
if (Language.ToUpper() == "VN")
{
ctrMain.Text = sVnText.Replace("&BranchName","VIETNAM");
}
else
{
ctrMain.Text = sEnText.Replace("&BranchName", "VIETNAM");
}
UserControl UC = new UserControl();
foreach (Control ctr in ctrMain.Controls)
{
// if (ctr is Janus.Windows.UI.Tab.UITab || ctr is Janus.Windows.UI.Tab.UITabPage || ctr is TabControl || ctr is TabPage || ctr is StatusStrip || ctr is UserControl || ctr is ToolStrip || ctr is Label || ctr is Button || ctr is GroupBox || ctr is CheckBox || ctr is RadioButton || ctr is Panel || ctr is ComboBox || ctr is TextBox)
if (ctr is TabControl || ctr is TabPage || ctr is StatusStrip || ctr is UserControl || ctr is ToolStrip || ctr is Label || ctr is Button || ctr is GroupBox || ctr is CheckBox || ctr is RadioButton || ctr is Panel || ctr is ComboBox || ctr is TextBox)
{
string CtrlName = ctr.Name;
if (ctr is Label)
{
if (ctr.Parent != null && ctr.Parent.GetType().BaseType.FullName == UC.GetType().FullName)
{
}
else
{
CtrlName = ctr.Parent.Name + "." + ctr.Name;
}
}
DataRow[] dr = null;
dr = DT1.Select("sFormName='" + ctrMain.Name + "' AND sControlName='" + CtrlName + "'");
if (dr.GetLength(0) > 0)
{
if (Language.ToUpper() == "VN")
{
if (ctr is ComboBox)
{
ComboBox cbo = null;
string[] splt = sDBnull(dr[0]["sVn"].ToString(), "").Split(',');
cbo = (ComboBox)ctr;
cbo.Items.Clear();
for (int i = 0; i <= splt.GetLength(0) - 1; i++)
{
cbo.Items.Add(splt[i]);
}
}
else
{
if (sDBnull(dr[0]["TTT"], "").ToString() == "1")
示例9: SetViewStyle
private void SetViewStyle(UserControl view, int position)
{
// find the style
for(int i = 0; i < filterStyles.Length; i++) {
Type[] types = filterStyles[i].Types;
int count = types.Length;
for(int j = 0; j < count; j++) {
if(view.GetType() == types[j]) {
// found
view.BackColor = position % 2 == 0 ? filterStyles[i].BackColor1 : filterStyles[i].BackColor2;
return;
}
}
}
}