我无法获得K k krypton Textbox名称C#
我有C#中的Winform项目。我在我的项目中添加K k k king,以提高视觉质量。我添加了来自K k k的文本框控件。但不幸的是,我对文本框事件有问题。我无法获得文本框名称。
这些是我的代码:
private void TextBox_Click(object sender, EventArgs e)
{
string tbName = string.Empty;
// I tried this but it gives me t as null
//KryptonTextBox t=sender as KryptonTextBox;
// tbName= t.Name;
// It gives me textbox name is empty ""
TextBox tb = sender as TextBox;
tbName = tb.Name;
tbName = tb.AccessibleName; // give me null
tbName = tb.Tag.ToString(); // give me null
// I tried @ Jimi's advice
Control c = sender as Control;
tbName = c.Name; // it gives me empty
tbName = c.AccessibleName; // give me null
tbName = c.Tag.ToString();// give me null
// it react like it isn't KryptonToolbox, so passed the if condition.
if (c is KryptonTextBox)
{
tbName = (c as KryptonTextBox).Name;
}
if (c is TextBox)
{
tbName = (c as TextBox).Name; // gives me empty.
}
}
编辑: @null博士建议的方式是有效的。我添加了
kryptonTextBox1.Textbox.Name="kryptonTextbox1";
I have winform project in C#. I add Krypton Toolkits to my project for visual quality. I added TextBox control from Krypton Toolkit. But unfortunately I have a problem with textbox events. I couldn't get Textbox name.
These are my codes :
private void TextBox_Click(object sender, EventArgs e)
{
string tbName = string.Empty;
// I tried this but it gives me t as null
//KryptonTextBox t=sender as KryptonTextBox;
// tbName= t.Name;
// It gives me textbox name is empty ""
TextBox tb = sender as TextBox;
tbName = tb.Name;
tbName = tb.AccessibleName; // give me null
tbName = tb.Tag.ToString(); // give me null
// I tried @ Jimi's advice
Control c = sender as Control;
tbName = c.Name; // it gives me empty
tbName = c.AccessibleName; // give me null
tbName = c.Tag.ToString();// give me null
// it react like it isn't KryptonToolbox, so passed the if condition.
if (c is KryptonTextBox)
{
tbName = (c as KryptonTextBox).Name;
}
if (c is TextBox)
{
tbName = (c as TextBox).Name; // gives me empty.
}
}
Edit: The way @dr.null has suggested is worked. I added
kryptonTextBox1.Textbox.Name="kryptonTextbox1";
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论