|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VB.NET ComboBox _SelectedIndexChangedIn my _SelectedIndexChanged event for the combobox, if changes to the panel's controls are present I am checking the response from a messagebox to proceed using MsgBoxStyle.YesNoCancel. When clicking cancel on the messagebox, is there a way to have the combobox rejected the changed index and revert back to the previous selection without setting the selectedItem? Currently getting circular references when doing that. Code: Private Sub cboPage_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboPage.SelectedIndexChanged If Not CInt(sender.SelectedItem.Value) <> _currentSetMax Then If ItemsModified Then Select Case MsgBox("Changes have been made, Save changes?", MsgBoxStyle.YesNoCancel, "Items Changed") Case MsgBoxResult.Yes ' TO DO: Save the existing controls in the panel Case MsgBoxResult.Cancel 'TO DO: Reset the cboPage to the previous selection and return Return End Select End If ' TO DO: Refresh the controls in the panel End If End Sub Thanks! -- ..NET wannabe I would store the current setting in a variable or xml document and if the
change was rejected set the previous entry as currently selected item (index) -- Show quoteHide quoteGet a powerful web, database, application, and email hosting with KJM Solutions http://www.kjmsolutions.com "MachuPicchu" <MachuPic***@discussions.microsoft.com> wrote in message news:E11D1919-E039-435E-AD27-5E76F0AC16DA@microsoft.com... > Hi, I'm refreshing a panel based on a selection from a winforms combobox. > In my _SelectedIndexChanged event for the combobox, if changes to the > panel's controls are present I am checking the response from a messagebox > to > proceed using MsgBoxStyle.YesNoCancel. > > When clicking cancel on the messagebox, is there a way to have the > combobox > rejected the changed index and revert back to the previous selection > without > setting the selectedItem? Currently getting circular references when doing > that. > > Code: > > Private Sub cboPage_SelectedIndexChanged(ByVal sender As System.Object, > ByVal e As System.EventArgs) Handles cboPage.SelectedIndexChanged > If Not CInt(sender.SelectedItem.Value) <> _currentSetMax Then > > If ItemsModified Then > > Select Case MsgBox("Changes have been made, Save changes?", > MsgBoxStyle.YesNoCancel, "Items Changed") > Case MsgBoxResult.Yes > ' TO DO: Save the existing controls in the panel > Case MsgBoxResult.Cancel > 'TO DO: Reset the cboPage to the previous selection and return > Return > End Select > > End If > ' TO DO: Refresh the controls in the panel > > End If > > End Sub > > Thanks! > > > > -- > .NET wannabe > I never found a way, I believe that once this event is fired the index was
already changed what you can do is to record to a static or class variable the index of the selected item (After you approved the change) then if you don't like the change you reset it to the previous recorded index Then finally to avoid the method functionality you can Add a condition like that if ComboABC.SelectedIndex = iRecordedIndex then 'Ignore and exit Else 'Perform the required functionality ...... End if hth, Samuel Shulman Show quoteHide quote "MachuPicchu" <MachuPic***@discussions.microsoft.com> wrote in message news:E11D1919-E039-435E-AD27-5E76F0AC16DA@microsoft.com... > Hi, I'm refreshing a panel based on a selection from a winforms combobox. > In my _SelectedIndexChanged event for the combobox, if changes to the > panel's controls are present I am checking the response from a messagebox > to > proceed using MsgBoxStyle.YesNoCancel. > > When clicking cancel on the messagebox, is there a way to have the > combobox > rejected the changed index and revert back to the previous selection > without > setting the selectedItem? Currently getting circular references when doing > that. > > Code: > > Private Sub cboPage_SelectedIndexChanged(ByVal sender As System.Object, > ByVal e As System.EventArgs) Handles cboPage.SelectedIndexChanged > If Not CInt(sender.SelectedItem.Value) <> _currentSetMax Then > > If ItemsModified Then > > Select Case MsgBox("Changes have been made, Save changes?", > MsgBoxStyle.YesNoCancel, "Items Changed") > Case MsgBoxResult.Yes > ' TO DO: Save the existing controls in the panel > Case MsgBoxResult.Cancel > 'TO DO: Reset the cboPage to the previous selection and return > Return > End Select > > End If > ' TO DO: Refresh the controls in the panel > > End If > > End Sub > > Thanks! > > > > -- > .NET wannabe > Thanks Samuel!
I knew there had to be a workaround. Recalling my PowerBuilder days when what I described was possible and didn't know if it could be handled in VB.Net as I described. -- Show quoteHide quote..NET developer VS.NET 2005 Rocks! "Samuel Shulman" wrote: > I never found a way, I believe that once this event is fired the index was > already changed > > what you can do is to record to a static or class variable the index of the > selected item (After you approved the change) then if you don't like the > change you reset it to the previous recorded index > Then finally to avoid the method functionality you can Add a condition like > that > > if ComboABC.SelectedIndex = iRecordedIndex then > 'Ignore and exit > Else > 'Perform the required functionality > ...... > End if > > > hth, > Samuel Shulman > > "MachuPicchu" <MachuPic***@discussions.microsoft.com> wrote in message > news:E11D1919-E039-435E-AD27-5E76F0AC16DA@microsoft.com... > > Hi, I'm refreshing a panel based on a selection from a winforms combobox. > > In my _SelectedIndexChanged event for the combobox, if changes to the > > panel's controls are present I am checking the response from a messagebox > > to > > proceed using MsgBoxStyle.YesNoCancel. > > > > When clicking cancel on the messagebox, is there a way to have the > > combobox > > rejected the changed index and revert back to the previous selection > > without > > setting the selectedItem? Currently getting circular references when doing > > that. > > > > Code: > > > > Private Sub cboPage_SelectedIndexChanged(ByVal sender As System.Object, > > ByVal e As System.EventArgs) Handles cboPage.SelectedIndexChanged > > If Not CInt(sender.SelectedItem.Value) <> _currentSetMax Then > > > > If ItemsModified Then > > > > Select Case MsgBox("Changes have been made, Save changes?", > > MsgBoxStyle.YesNoCancel, "Items Changed") > > Case MsgBoxResult.Yes > > ' TO DO: Save the existing controls in the panel > > Case MsgBoxResult.Cancel > > 'TO DO: Reset the cboPage to the previous selection and return > > Return > > End Select > > > > End If > > ' TO DO: Refresh the controls in the panel > > > > End If > > > > End Sub > > > > Thanks! > > > > > > > > -- > > .NET wannabe > > > > >
Validating textbox w/ Cancel button
sql server 2005 tools configuration starts when I build a distribution project (VB 2005) Delegate et al TypeForwardedToApp attribute. Replacement for Inet Control text justification in excel ComboBox in DataGrid How to compare two identical tables in VB.NET + MS Access Determine projects in solution within VS2005 macro Checked List Box Help |
|||||||||||||||||||||||