Reputation: 497
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";
Upvotes: 0
Views: 183