Victor Charles
asked on
How do I cancel a deselection or reselect the row deselected after I press the NO button?
Hi,
I'm using the code below to disable controls if user clicks Yes after deselecting a row, problem is if they select NO, the row deselected remains deselected, ist here a way to automatically reselect the row deselected when the user presses No?
The code is in the lostfocus event of my C1TrueDBGrid control or should the code be placed in another section?
If countrepeatedchar("0,1,2,3 ,4", "4") >= 1 And C1MunitionType.SelectedRow s.Count = 1 Then
va = 1
C1OMT.Enabled = True
LO.BackColor = Color.Yellow
C1ImageA.Text = ""
Else
If C1OMT.Text <> "" Then
Dim anadd As String = Nothing
anadd = MsgBox("Related information (OMT) on screen 4 for will also be deleted are you sure you want to deselect?", MsgBoxStyle.YesNo, "Warning before Attempting deselect Item")
If anadd = MsgBoxResult.Yes Then
C1OMT.Enabled = False
LO.BackColor = Color.LightGray
C1OMT.Text = ""
End If
End If
End If
Thanks,
Victor
I'm using the code below to disable controls if user clicks Yes after deselecting a row, problem is if they select NO, the row deselected remains deselected, ist here a way to automatically reselect the row deselected when the user presses No?
The code is in the lostfocus event of my C1TrueDBGrid control or should the code be placed in another section?
If countrepeatedchar("0,1,2,3
va = 1
C1OMT.Enabled = True
LO.BackColor = Color.Yellow
C1ImageA.Text = ""
Else
If C1OMT.Text <> "" Then
Dim anadd As String = Nothing
anadd = MsgBox("Related information (OMT) on screen 4 for will also be deleted are you sure you want to deselect?", MsgBoxStyle.YesNo, "Warning before Attempting deselect Item")
If anadd = MsgBoxResult.Yes Then
C1OMT.Enabled = False
LO.BackColor = Color.LightGray
C1OMT.Text = ""
End If
End If
End If
Thanks,
Victor
You can call the Focus method to refocus the control. Is user clicking on another row within grid or outside grid?
ASKER
By refocus the control, do you mean the row deselected would be reselected? When I click on a row within the Grid I receive a message box to select Yes or No.
I moved the code to the BeforeRowColChange in order to get confirmation message each time I deselect a row, but unable to reselect when I press No.
I moved the code to the BeforeRowColChange in order to get confirmation message each time I deselect a row, but unable to reselect when I press No.
When pressing no, you need to set e.cancel to true.
ASKER
Or By refocus the control to you mean forcing the user to reselect the row if they Press No?
Can you please send me an example for either approach.
Thanks,
Victor
Can you please send me an example for either approach.
Thanks,
Victor
I recommended Focus because you said you have that code in LostFocus event. Try with e.cancel approach I suggested above.
ASKER
OK, will try it and get back to you, since I know the exact row, is there also a way set set the row to select = true. For example
If anadd = MsgBoxResult.Yes Then
C1OMT.Enabled = False
LO.BackColor = Color.LightGray
C1OMT.Text = ""
Else
C1NSN.row(1).select = True
End If
Thanks,
V.
If anadd = MsgBoxResult.Yes Then
C1OMT.Enabled = False
LO.BackColor = Color.LightGray
C1OMT.Text = ""
Else
C1NSN.row(1).select = True
End If
Thanks,
V.
ASKER
Hi,
e.cancel is not a property of the Grid. I tried Me.C1Manufacturer.Selected Rows.Add(0 ) but it did not work.
I tried the following code:
If countrepeatedchar("0,1,2,3 ,4", "0") >= 1 Then
C1ImageA.Text = "Image_1.jpg"
Else
If C1LocationA.Text <> "Select" Then
Dim anadd As String = Nothing
anadd = MsgBox("are you sure you want to deselect?", MsgBoxStyle.YesNo, "Warning before Attempting deselect")
If anadd = MsgBoxResult.Yes Then
C1LocationA.Enabled = False
End If
If anadd = MsgBoxResult.No Then
Me.C1Manufacturer.Selected Rows.Add(0 ) ' Row (0) is not selected and highlighted
Exit Sub
End If
End If
Thanks,
Victor
e.cancel is not a property of the Grid. I tried Me.C1Manufacturer.Selected
I tried the following code:
If countrepeatedchar("0,1,2,3
C1ImageA.Text = "Image_1.jpg"
Else
If C1LocationA.Text <> "Select" Then
Dim anadd As String = Nothing
anadd = MsgBox("are you sure you want to deselect?", MsgBoxStyle.YesNo, "Warning before Attempting deselect")
If anadd = MsgBoxResult.Yes Then
C1LocationA.Enabled = False
End If
If anadd = MsgBoxResult.No Then
Me.C1Manufacturer.Selected
Exit Sub
End If
End If
Thanks,
Victor
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.