Click here to Skip to main content
15,915,513 members
Home / Discussions / C#
   

C#

 
GeneralCompile and execute code Pin
lindiwe29-Mar-05 23:23
lindiwe29-Mar-05 23:23 
GeneralRe: Compile and execute code Pin
Stanciu Vlad29-Mar-05 23:43
Stanciu Vlad29-Mar-05 23:43 
GeneralRe: Compile and execute code Pin
Sebastian Schneider30-Mar-05 0:02
Sebastian Schneider30-Mar-05 0:02 
GeneralRe: Compile and execute code Pin
Kodanda Pani30-Mar-05 2:29
Kodanda Pani30-Mar-05 2:29 
Generalsystem class Pin
computer_eng29-Mar-05 22:50
computer_eng29-Mar-05 22:50 
GeneralRe: system class Pin
Sabry190529-Mar-05 23:55
Sabry190529-Mar-05 23:55 
GeneralRe: system class Pin
AristotleYu13-Jun-05 22:15
AristotleYu13-Jun-05 22:15 
Generalclose a dialog box when a text box has focus Pin
steve_rm29-Mar-05 22:05
steve_rm29-Mar-05 22:05 
Hello

I have a very difficult problem to explain. I have a password dialog box so that people can change there password. The dialog box will request for their current password, anc check that is is valid. Then request them to enter their new password and then re-enter their new password. The passwords are checked using the tab button when they leave a text box on the (leave event). When they have done all this they click the ok button and the new password is set. If however, they cancel using the cancel button. Then the dialog box will not close. This is the code below so you can better understand my problem.

This is the code for when the user enters the password, and presses the tab key to go to the next text box. When this event fires it will check the password is correct. Enter new password and re-enter password uses the same idea. I will not post it here as the code is the same.

<br />
private void txtEnterPassword_Leave(object sender, System.EventArgs e)<br />
		{<br />
			string queryValidatePwd = "SELECT Username, Password FROM AdminUsers WHERE Username = '" + lblLoginName.Text + "' AND Password = '" + txtEnterPassword.Text + "' ";<br />
<br />
			try<br />
			{<br />
				OleDbCommand cmdValidatePwd = cnnChangePassword.CreateCommand();<br />
				cmdValidatePwd.CommandType = CommandType.Text;<br />
				cmdValidatePwd.CommandText = queryValidatePwd;<br />
<br />
				OleDbDataAdapter daValidatePwd = new OleDbDataAdapter(cmdValidatePwd);<br />
				DataTable dtValidatePwd = new DataTable("AdminUsers");<br />
				<br />
				int count = daValidatePwd.Fill(dtValidatePwd);<br />
				if ( daValidatePwd.Fill(dtValidatePwd) == 1 ) //Password is correct<br />
				{<br />
					txtEnterNewPassword.Visible = true;<br />
					txtEnterNewPassword.Focus(); //Get focus of next text box.<br />
				}<br />
				else<br />
				{<br />
					MessageBox.Show("Password is incorrect for this username - please try again","Incorrect Password",MessageBoxButtons.OK,MessageBoxIcon.Warning);<br />
					txtEnterPassword.Clear();<br />
					txtEnterPassword.Focus();<br />
				}<br />
				dtValidatePwd.Dispose();<br />
				daValidatePwd.Dispose();		<br />
			}<br />
			catch ( OleDbException ex )<br />
			{<br />
				MessageBox.Show(ex.Message);<br />
			}<br />
			catch ( Exception ex )<br />
			{<br />
				MessageBox.Show(ex.Message);<br />
			}<br />
		}<br />


Code for when the user closes the dialog box. The the other textboxes have focus you cannot close this form. I have tired using this.close() as well, but still does not work.
<br />
private void btnCancel_Click(object sender, System.EventArgs e)<br />
{<br />
	this.Dispose();<br />
}<br />


Thanks for you help in advance,

Steve
GeneralRe: close a dialog box when a text box has focus Pin
Stanciu Vlad29-Mar-05 22:30
Stanciu Vlad29-Mar-05 22:30 
GeneralRe: close a dialog box when a text box has focus Pin
Luis Alonso Ramos30-Mar-05 7:49
Luis Alonso Ramos30-Mar-05 7:49 
GeneralRe: close a dialog box when a text box has focus Pin
S. Senthil Kumar30-Mar-05 19:30
S. Senthil Kumar30-Mar-05 19:30 
Generalwin32 datatype in C#.NET Pin
Babarsaeed29-Mar-05 22:00
Babarsaeed29-Mar-05 22:00 
GeneralRe: win32 datatype in C#.NET Pin
Stanciu Vlad29-Mar-05 22:10
Stanciu Vlad29-Mar-05 22:10 
GeneralRe: win32 datatype in C#.NET Pin
Anonymous1-Apr-05 17:26
Anonymous1-Apr-05 17:26 
GeneralRe: win32 datatype in C#.NET Pin
Stanciu Vlad1-Apr-05 20:02
Stanciu Vlad1-Apr-05 20:02 
GeneralC# Project for different OS Pin
bosfan29-Mar-05 20:23
bosfan29-Mar-05 20:23 
GeneralRe: C# Project for different OS Pin
mav.northwind29-Mar-05 21:05
mav.northwind29-Mar-05 21:05 
GeneralRe: C# Project for different OS Pin
Sebastian Schneider29-Mar-05 21:10
Sebastian Schneider29-Mar-05 21:10 
GeneralRe: C# Project for different OS Pin
J4amieC29-Mar-05 21:15
J4amieC29-Mar-05 21:15 
GeneralRe: C# Project for different OS Pin
DavidNohejl29-Mar-05 21:48
DavidNohejl29-Mar-05 21:48 
GeneralRe: C# Project for different OS Pin
bosfan30-Mar-05 0:58
bosfan30-Mar-05 0:58 
GeneralRe: C# Project for different OS Pin
Stanciu Vlad29-Mar-05 22:01
Stanciu Vlad29-Mar-05 22:01 
GeneralAdding Mails to a Folder in Outlook programmatically Pin
ShwetaRokade29-Mar-05 19:55
ShwetaRokade29-Mar-05 19:55 
GeneralA new question Pin
shaima'29-Mar-05 19:43
shaima'29-Mar-05 19:43 
GeneralRerading a Text File with Advance Options.... Pin
Anonymous29-Mar-05 19:17
Anonymous29-Mar-05 19:17 

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.