Alright I am going to try to put this in the least confusing way possible. I have a form that contains multiple textboxes. These textboxes are initially disabled and their text has been grabbed from a file that has been read in. No problems yet. There are 20 lines that are read in and these "should" never be changed but I want to let the user have the opportunity (with a strict warning of course). So I have setup checkboxes next to each line that if clicked, the textboxes for that line become enabled and the user can change the text. If the user clicks the checkbox I have a YesNoCancel dialog popup and if the user clicks 'No' I want the textboxes for that line to remain disabled [/I]and[/I] the checkbox to revert back to being unchecked.
Here's my problem. Let's say the user does click yes when clicking the checkbox. He/She then makes changes to the textboxes. Then, "oops!" those changes were wrong. So then the user would click on the checkbox again only this time (since it was already checked) a different YesNoCancel dialog comes up but this time saying "Revert to Defaults?". Everything I've tried ends up displaying two dialog boxes.
Private Sub chkLine1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkLine1.CheckedChanged If chkLine1.CheckState = CheckState.Checked Then If MessageBox.Show("Are you sure you want to change the Header field values?", "Change Header Fields", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation) = Windows.Forms.DialogResult.Yes Then txtLn01_DefaultText.Enabled = True txtLn01_StartDate.Enabled = True txtLn01_StartTime.Enabled = True Else chkLine1.Checked = False txtLn01_DefaultText.Enabled = False txtLn01_StartDate.Enabled = False txtLn01_StartTime.Enabled = False End If [B]Else[/B] If MessageBox.Show("Are you sure? Doing so will cause all values to be reset to their defaults.", "Reset to Defaults?", MessageBoxButtons.YesNoCancel) = Windows.Forms.DialogResult.Yes Then txtLn01_DefaultText.Enabled = False txtLn01_StartDate.Enabled = False txtLn01_StartTime.Enabled = False txtLn01_DefaultText.Text = AD.DF.Header.Ln01_DefaultText txtLn01_StartDate.Text = AD.DF.Header.Ln01_StartDate txtLn01_StartTime.Text = AD.DF.Header.Ln01_StartTime End If End If End Sub
Basically what I need to know is: how can I make a checkbox, after its been clicked, not change its state until the user clicks yes or no?
Edited 6 Years Ago by Tweed: n/a