CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2017
    Posts
    23

    [RESOLVED] Problem with Visual C++

    Hello.
    I'm writing some program, and I stuck on default ComboBox value.
    In my Form application my form.h [project] is generating code automatically. But in property box there is no "SelectedIndex" or "SelectedItem" or "SelectedText".
    This is my code:

    Code:
    // 
    			// GUI_Combo_Swiat
    			// 
    			this->GUI_Combo_Swiat->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
    			this->GUI_Combo_Swiat->FormattingEnabled = true;
    			this->GUI_Combo_Swiat->Items->AddRange( gcnew cli::array< System::Object^  >( 4 )
    			{
    				L"- Wybierz Świat -", L"Świat 1", L"Świat 2",
    					L"Świat 110"
    			} );
    			this->GUI_Combo_Swiat->Location = System::Drawing::Point( 458, 98 );
    			this->GUI_Combo_Swiat->MaxDropDownItems = 20;
    			this->GUI_Combo_Swiat->Name = L"GUI_Combo_Swiat";
    			this->GUI_Combo_Swiat->Size = System::Drawing::Size( 121, 21 );
    			this->GUI_Combo_Swiat->TabIndex = 0;
    When I'm writing manualy this kind of code:
    Code:
    this->GUI_Combo_Swiat->SelectedIndex = 0;
    It works until I won't make some changes in ANY control. After that IDE is automatically removing my line of code, and combobox is starting empty again...
    Could you please help me?
    Greetings, genotypek.
    Last edited by Genotypek; April 27th, 2017 at 02:27 PM.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Problem with Visual C++

    The thread was moved from Visual C++ forum because the posted code is no a native C++.
    Victor Nijegorodov

  3. #3
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Problem with Visual C++

    Don't ever apply any manual changes to the code inside InitializeComponent()! Your changes being overwritten by Forms Designer is just the most harmless result you can get. You may also completely mess up the designer.

    Instead, put initialization code like this into your form's constructor, after the call to InitializeComponent().
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  4. #4
    Join Date
    Apr 2017
    Posts
    23

    Re: Problem with Visual C++

    Thanks a lot!
    That works! ☺

    I didn't even know, that the kind of code where I can write my code manually even exists.
    Thanks for help, problem solved.
    Greetings, genotypek.

  5. #5
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Problem with Visual C++

    You're welcome.

    This may be the time to mark this thread [RESOLVED] using the Thread Tools menu at the top. This is a signal to other users that there's a solution in here.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured