Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
Recently I had developed a user control by inheriting the Textbox in which I have just added 1 property "isValidate" whose data type is boolean. Now the problem I am facing is, when I write "this.ActiveControl" I cannot see the "isValidate" property as the "Control" class does not posess the "isValidate" property. So, any idea how to manage this problem?

Thanks in advance
Posted
Updated 18-Feb-15 23:50pm
v2
Comments
Sergey Alexandrovich Kryukov 19-Feb-15 2:51am    
How come, if you added it? "Cannot see" — where? If you really added it (what is the access modifier?), it's there.
Anyway, how are we supposed to find your bug without adequate code sample?
—SA
agent_kruger 19-Feb-15 3:26am    
see sir, i have created a user control inherited a textbox now what i wanted was that whenever i type "this.ActiveControl" i want to see the custom property of the textbox named "IsValidate" and the code should look like this "this.ActiveControl.IsValidate" but "isvalidate" wont show as it is not present in the "Control class" and thats where i need your help

1 solution

That's easy. Let's assume your control class name is MyTextBox. Now you do this
C#
MyTextBox txtBox = this.ActiveControl as MyTextBox;
if (txtBox != null)
{
  //Bingo, the active control is MyTextBox
  //Accessing IsValidate property
  txtBox.IsValidate = false;
}

Of course, make sure your property is public.
 
Share this answer
 
Comments
agent_kruger 23-Feb-15 4:50am    
that was just simple, why didn't i think of that btw. thanks man

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900