Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with custom control in design view

Status
Not open for further replies.

arevans

Programmer
Aug 21, 2007
5
US
I created a custom control that inherits from textbox in a separate project (class library) in my solution. The custom control appears in the toolbox. I added a reference in my main project to the class library project. I can drag it to a form OK, but if I click away from it to another control, I can't click back. Yet, if I drag another control to the form, say a label, and then delete the label, focus jumps to my custom control again. Anybody know what is going on here?

Thanks,

arevans
 
How are you creating your custom textbox?

Did you create a UserControl or did you write a class that inherits from TextBox?

public class MyTextBox : System.Windows.Forms.TextBox

 
I figured it out. I was trying to build a numeric text box control with the code below. After I deleted it, it worked fine!

public override bool PreProcessMessage(ref Message msg)
{
Keys thisKey = (Keys)msg.WParam.ToInt32();
bool isNumber = ((thisKey >= Keys.D0 && thisKey <= Keys.D9) || (thisKey >= Keys.NumPad0 && thisKey <= Keys.NumPad9));
if (isNumber)
{
return false;
} // if
else
{
return true;
} // else
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top