![]() |
|
[C#] Themed textbox keypress event not working - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C#] Themed textbox keypress event not working (/showthread.php?tid=5351497) |
Themed textbox keypress event not working - tenalp eht kcah - Jul 25, 2016 Hi, when using no theme the following code works properly to only allow number input to textbox: Code private void textBox1_KeyPress(object sender, KeyPressEventArgs e)Code this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(textBox1_KeyPress);But when I use a theme with the exact same code (textBox1) replaced with proper name, it does not work and the user can input any character. How can I fix this? * - CoderEX - Jul 25, 2016 Did you set the property event to the themed-textbox? Simply changing the event name over to the themed textbox's name will not work. * - tenalp eht kcah - Jul 25, 2016 (Jul 25, 2016 05:12 PM)[+] Tranquility [+] Wrote: Did you set the property event to the themed-textbox? The modified code looks like this and these are the only changes I've made: Code private void themedTextBox1_KeyPress(object sender, KeyPressEventArgs e)Code this.themedTextBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(themedTextBox1_KeyPress);* - 6e756c6c - Jul 26, 2016 Most of those themed TextBoxes are just regular TextBoxes inside of a parent container. Once you focus the child textbox, the parent events are ignored. You need to handle this event inside of the "ThemedTextBox" class. Alternatively, you could look into MintUI which themes an actual TextBox control and doesn't use some hacky workaround. https://github.com/CodeRail/MintUI |