Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6077069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:40:46+00:00 2026-05-23T10:40:46+00:00

I am writing on c# with visual interface. Part of the logic consists of

  • 0

I am writing on c# with visual interface. Part of the logic consists of a set of values changing depended on which one of them (sets) is selected in the combo box.

Changes in the value sets can be saved or not. There is a need to offer an opportunity for user to save unsaved changes or reject them when he chooses a different item (set) in the combo box. It is imperative that when the message box with yes/no is presented combo box still displayed the old value, and only after that, depending on user’s choice displayed new or old.

The sequence should be:

user uses keys or drop-down to select new item -> event is fired and form stops all of its processing -> my code cancels the change or lets it go through -> (if not cancelled) combo box is redrawn with new value.

N.B. Following events were tried and proved not to be adequate:

  • SelectedIndexChanged
  • SelectedValueChanged
  • SelectionChangeCommitted
  • Validating
  • DropDownClosed
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:40:46+00:00Added an answer on May 23, 2026 at 10:40 am

    I have found somewhat acceptable solution, although not directly corresponding to the verbatium of the question asked.

    One possible solution, though, sadly, for some reason deleted by his suggestor, was to use message filters. That, however, led to the path of manually calculating where the mouse click went and essentially substituting the winforms capabilities of translating the mouse events to the process of changing selected item in dropped list of the combo box with some crude crutches on my own. This is the path i shied from.

    In the end i settled on “cosmetic” solution, with the idea being substitution of displayed text in combo box for the duration of user’s decision-making on the subject of whether or not cancel the change.

    So, in the SelectedIndexChanged event i’ve put the follofing code:

    try
    {
        if (MyDataSets.Current.HasChanges() && !MyDataSets.Current.Name.Equals(cbChosenDataSet.Value))
        {
            cbChosenDataSet.DropDownStyle = ComboBoxStyle.DropDown;
            cbChosenDataSet.Text = MyDataSets.Current.Name + ' ';
            Application.DoEvents();
        }
        else return;
        /*
         * UserChoseToCancel is set according to user's choice
         */
        if (UserChoseToCancel)
            cbChosenDataSet.Value = MyDataSets.Current.Name;
        else
            MyDataSets.SetCurrent(cbChosenDataSet.Value);
        /*
         * other things
         */
    }
    catch(Exception e) {/* handling */}
    finally
    {
        cbChosenDataSet.DropDownStyle = ComboBoxStyle.DropDownList;
    }
    

    The gist of the idea is this: in DropDown style ComboBox’ text can be changed as needed. However, when set to one of the items in the list, a change of selection will occur. To avoid that unneededly, a space is added to the temporary text.

    In case cancelling does not occurs, restoring of the style to DropDownList forces the text to be changed to the actual chosen value (which has remained the same).

    In case user cancels the change, value of the combo box is set back to the old one. A check in the beginning of the handler stops the event generated by that from being processed further.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a extension for visual studio, which will automatically generate some JS
I'm writing a visual web part in visual studio for sharepoint 2010. The whole
I'm writing a program in Visual Basic 2010. It's a HMI (Human-Machine Interface) and
Today while writing some Visual C++ code I have come across something which has
I am writing a Visual Basic IDE, and I need to add lines numbers
Recently I spent quite some time writing various Visual Studio Extensions projects. Even though
I'm writing code in Visual C++ and I need to use a global variable.
I am writing my custom visual component and find it convenient to publish some
I'm writing a small Windows application in Visual C++ without MVC. Its really small,
I'm writing an application in Visual Basic to tell the user about their PC.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.