We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Input box

Thread ID:

Created:

Updated:

Platform:

Replies:

5000 Jun 13,2003 12:34 AM Jun 25,2003 08:12 AM Windows Forms 3
loading
Tags: FAQ
Yogendra Patil
Asked On June 13, 2003 12:34 AM

I am using an inputbox to allow the user to input some value. If the user doesnt enter anything and clicks OK Button, i want to display a message box asking for input and show the same input box again. If the user doesnt enter anything and clicks cancel button, then no messagebox to be displayed. How do i get through this?

Ramesh Praveen [Syncfusion]
Replied On June 25, 2003 07:44 AM

Listen to the OK button's click event, and if a valid value is not in the textbox, fire a message box and then set the focus back to the textbox; otherwise close the dialog by setting it's DialogResult value approriately. Note that the DialogResult property for this button control should be set to None. -Praveen

Ramesh Praveen [Syncfusion]
Replied On June 25, 2003 07:56 AM

Example: private void okButton_Click(object sender, System.EventArgs e) { if(this.textBox1.Text == String.Empty) MessageBox.Show("Invalid value entered."); else this.DialogResult = DialogResult.OK; }

Ramesh Praveen [Syncfusion]
Replied On June 25, 2003 08:12 AM

Here is another way of doing it: private void TextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) { if (!this.cancelButton_.Focused) { // Do this only when the cancel button is not clicked. if(invalidState) e.Cancel = true; } }

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;