Click here to Skip to main content
15,913,570 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: How to set focus in CheckBox placed in User Control. Pin
dan!sh 27-Nov-09 0:26
professional dan!sh 27-Nov-09 0:26 
GeneralRe: How to set focus in CheckBox placed in User Control. Pin
Madhumanjuri Mitra27-Nov-09 1:49
Madhumanjuri Mitra27-Nov-09 1:49 
GeneralRe: How to set focus in CheckBox placed in User Control. Pin
Shameel27-Nov-09 1:57
professionalShameel27-Nov-09 1:57 
GeneralRe: How to set focus in CheckBox placed in User Control. Pin
Madhumanjuri Mitra27-Nov-09 2:22
Madhumanjuri Mitra27-Nov-09 2:22 
GeneralRe: How to set focus in CheckBox placed in User Control. Pin
Shameel27-Nov-09 2:41
professionalShameel27-Nov-09 2:41 
GeneralRe: How to set focus in CheckBox placed in User Control. Pin
Madhumanjuri Mitra27-Nov-09 2:57
Madhumanjuri Mitra27-Nov-09 2:57 
GeneralRe: How to set focus in CheckBox placed in User Control. Pin
Shameel27-Nov-09 3:06
professionalShameel27-Nov-09 3:06 
GeneralRe: How to set focus in CheckBox placed in User Control. Pin
freakyit27-Nov-09 3:39
freakyit27-Nov-09 3:39 
hi,

try this one:

1. create your UserControl with the CheckBox inner it.

Code of UserControl:
<br />
dim checkBox1 as new CheckBox<br />
this.Controls.Add(checkBox1)<br />


2. in your main Form where the UserControl is the underlaying control, override the KeyPress event.
Code of MainForm:
sub override MainFormKeyPress(byval ...,....)<br />
for each userControl in this.Controls<br />
if userControl is nextUserControl then 'change if clause that is matches with your conditions <br />
<br />
userControl.KeyPress(byval..,...) 'send the parameter coming from above<br />
set nextUserControl = ... 'get the followed usercontrol of that one line above...<br />
<br />
end if<br />
<br />
next<br />
end sub


3. Send the KeyPress event to the UserControl. (UserControl1.KeyPress or like that, if this function doesn't exists create a public function in your UserControl name KeyPressEvent...)
-> step 4 is not required if you make your own KeyPress function.

4. Override the KeyPress event in the UserControl.
5. In your UserControl handle the KeyPressEvent raised from Main Form... to set the focus to the CheckBox.

sub override UserControlKeyPress(byval ...,....)<br />
for each userControl in this.Controls<br />
if arg.Key is Keys.Return then 'change it clause that is matches with your conditions <br />
<br />
checkBox1.Focus<br />
<br />
end if<br />
<br />
next<br />
end sub


6. !!! This is required to have a correct handling of setting the focus to only one CheckBox !!!
-> In your Main Form KeyPress event you need to decide which UserControl has to receive the KeyPress event, if you don't do this all UserControls receive the Event and the last UserControl that handled the event will focus its checkBox...

7. i hope it works as expected Smile | :)

greetz
GeneralRe: How to set focus in CheckBox placed in User Control. Pin
Madhumanjuri Mitra30-Nov-09 20:12
Madhumanjuri Mitra30-Nov-09 20:12 
QuestionHow to decide whether a class is "internal" by .net reflection ? Pin
yoyota26-Nov-09 22:28
yoyota26-Nov-09 22:28 
AnswerRe: How to decide whether a class is "internal" by .net reflection ? Pin
dan!sh 26-Nov-09 23:58
professional dan!sh 26-Nov-09 23:58 
GeneralRe: How to decide whether a class is "internal" by .net reflection ? Pin
yoyota27-Nov-09 14:06
yoyota27-Nov-09 14:06 
GeneralRe: How to decide whether a class is "internal" by .net reflection ? Pin
dan!sh 28-Nov-09 5:49
professional dan!sh 28-Nov-09 5:49 
QuestionDisplaying a form from another Form Pin
Madhumanjuri Mitra25-Nov-09 20:58
Madhumanjuri Mitra25-Nov-09 20:58 
AnswerRe: Displaying a form from another Form Pin
Shameel25-Nov-09 23:39
professionalShameel25-Nov-09 23:39 
AnswerRe: Displaying a form from another Form Pin
dan!sh 26-Nov-09 19:35
professional dan!sh 26-Nov-09 19:35 
GeneralRe: Displaying a form from another Form Pin
Madhumanjuri Mitra26-Nov-09 21:18
Madhumanjuri Mitra26-Nov-09 21:18 
GeneralRe: Displaying a form from another Form Pin
dan!sh 26-Nov-09 21:52
professional dan!sh 26-Nov-09 21:52 
GeneralRe: Displaying a form from another Form Pin
Madhumanjuri Mitra26-Nov-09 22:33
Madhumanjuri Mitra26-Nov-09 22:33 
GeneralRe: Displaying a form from another Form Pin
dan!sh 26-Nov-09 23:17
professional dan!sh 26-Nov-09 23:17 
QuestionADO .NET & Parameterized Stored Procedures [modified] Pin
T210225-Nov-09 20:24
T210225-Nov-09 20:24 
AnswerRe: ADO .NET & Parameterized Stored Procedures Returning Recordset Pin
Ashfield25-Nov-09 21:17
Ashfield25-Nov-09 21:17 
GeneralRe: ADO .NET & Parameterized Stored Procedures Returning Recordset [modified] Pin
T210225-Nov-09 21:42
T210225-Nov-09 21:42 
GeneralRe: ADO .NET & Parameterized Stored Procedures Returning Recordset Pin
Ashfield26-Nov-09 1:14
Ashfield26-Nov-09 1:14 
GeneralRe: ADO .NET & Parameterized Stored Procedures Returning Recordset Pin
T210226-Nov-09 2:02
T210226-Nov-09 2:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.