bug in detecting keypress event....


hi everybody,

i developing window form application. using textboxes on form , has enable keypress event on form.but when debug cursor blinks in texbox , keypress event working. when click on other button cursor texbox disappears , form not detect keypress event.

in short keypress event occurs when cursor focus in textbox.

how can remov bug or detect keypress event if cursor not focusing on textboxes.

thanx in advace

regards

junaid manzoor


junaid

 

how can i [...] detect keypress event if cursor not focusing on textboxes.


hi,

you override processcmdkey-method in form detect keyevents:

(btw: not see bug in keypress-situation)

    public partial class form1 : form   {     private system.windows.forms.textbox textbox1 = new textbox();     public form1()     {       initializecomponent();        this.textbox1.location = new system.drawing.point(13, 13);       this.textbox1.name = "textbox1";       this.textbox1.size = new system.drawing.size(100, 20);       this.controls.add(this.textbox1);     }      protected override bool processcmdkey(ref message msg, keys keydata)     {       //notify keys...       messagebox.show(keydata.tostring());        if (keydata == keys.a)       {         //do on "a"         this.backcolor = color.green;          //return done method         //not no "a" written in textbox         return true;       }        return base.processcmdkey(ref msg, keydata);     }   }  
  regards,  
   thorsten  



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'