Click here to Skip to main content
15,886,110 members
Home / Discussions / C#
   

C#

 
GeneralRe: fill structure data using c# Pin
jalsa G24-May-09 6:25
jalsa G24-May-09 6:25 
GeneralRe: fill structure data using c# Pin
Luc Pattyn24-May-09 6:35
sitebuilderLuc Pattyn24-May-09 6:35 
GeneralRe: fill structure data using c# Pin
jalsa G24-May-09 6:44
jalsa G24-May-09 6:44 
GeneralRe: fill structure data using c# Pin
Luc Pattyn24-May-09 7:01
sitebuilderLuc Pattyn24-May-09 7:01 
Questioninsert datagridview items with foreach in to database Pin
h_floppy24-May-09 5:21
h_floppy24-May-09 5:21 
AnswerRe: insert datagridview items with foreach in to database Pin
dan!sh 24-May-09 5:24
professional dan!sh 24-May-09 5:24 
GeneralRe: insert datagridview items with foreach in to database Pin
fclose_fp24-May-11 8:01
fclose_fp24-May-11 8:01 
QuestionFocus in ToolStripControlHost after validating cancelled Pin
netogg24-May-09 4:24
netogg24-May-09 4:24 
Hello,

I've embedded a MaskedTextBox in a UserControl and added it to the ToolStrip of a Form via ToolStripControlHost:

private void Form1_Load(object sender, EventArgs e)
{
ToolStrip1.Items.Add(new ToolStripControlHost(new UserControl1()));
}

In the Validating event of the MaskedTextBox in my UserControl the value of the Text is checked and if necessary corrected:

private void maskedTextBox1_Validating(object sender, CancelEventArgs e)
{
if (maskedTextBox1.Text == "0")
{
maskedTextBox1.Text = "1";
maskedTextBox1.SelectAll();
e.Cancel = true;
}
}

The user can give any input in the MaskedTextBox, validation should only occur when "leaving". If the focus "leaves" the MaskedTextBox (by the user clicking anywhere or tabbing), validation is performed.

If validation fails ( in this case Text = "0") a corrected value ("1") is set, no events (e.g. button clicks) occur outside the control and the control's text should be highlighted

After the value was automatically corrected (the user has been shown a warning... not relevant), he can now of course "Leave" without ado.

If the UserControl is added to a Form all the described behaviour occurs.

However as the userControl is put in a ToolStripControlHost I can't get the text of the MaskedTextBox highlighted after the validation of the maskedtextbox (inside the toolstrip) fails.

Any help on this would be sincerely appreciated.
AnswerRe: Focus in ToolStripControlHost after validating cancelled Pin
netogg29-May-09 23:53
netogg29-May-09 23:53 
GeneralRe: Focus in ToolStripControlHost after validating cancelled Pin
acolight17-Mar-11 10:27
acolight17-Mar-11 10:27 
Question[Message Deleted] Pin
hkjghkj124-May-09 4:03
hkjghkj124-May-09 4:03 
AnswerRe: DataGridView and mdb Pin
Manas Bhardwaj24-May-09 4:20
professionalManas Bhardwaj24-May-09 4:20 
QuestionKeyPress Event Pin
Saiyed Alam24-May-09 0:58
Saiyed Alam24-May-09 0:58 
AnswerRe: KeyPress Event Pin
DaveyM6924-May-09 1:22
professionalDaveyM6924-May-09 1:22 
GeneralRe: KeyPress Event Pin
Saiyed Alam24-May-09 16:37
Saiyed Alam24-May-09 16:37 
Questionsearch in site Pin
michaelgr124-May-09 0:42
michaelgr124-May-09 0:42 
AnswerRe: search in site Pin
Manas Bhardwaj24-May-09 0:57
professionalManas Bhardwaj24-May-09 0:57 
GeneralRe: search in site Pin
michaelgr124-May-09 0:58
michaelgr124-May-09 0:58 
GeneralRe: search in site Pin
Manas Bhardwaj24-May-09 1:18
professionalManas Bhardwaj24-May-09 1:18 
GeneralRe: search in site Pin
michaelgr124-May-09 1:31
michaelgr124-May-09 1:31 
QuestionRefresh Datagrid Pin
KIDYA23-May-09 23:20
KIDYA23-May-09 23:20 
QuestionCalling Method of an Active Form from the MDI Parent Pin
uygarer23-May-09 23:13
uygarer23-May-09 23:13 
AnswerRe: Calling Method of an Active Form from the MDI Parent Pin
Moreno Airoldi24-May-09 0:12
Moreno Airoldi24-May-09 0:12 
AnswerRe: Calling Method of an Active Form from the MDI Parent Pin
DaveyM6924-May-09 0:25
professionalDaveyM6924-May-09 0:25 
QuestionFunction Caller Pin
Saiyed Alam23-May-09 22:56
Saiyed Alam23-May-09 22:56 

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.