Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • I cannot seem to set a default value of a ComboBoxEdit.

                                    Although the event handler fires after each of these statements, cboFindOption.SelectedText is "".
                                                cboFindOption.SelectedText = "RM Audit Trail";
                                                cboFindOption.SelectedIndex = 0;
                                                cboFindOption.EditValue = "RM Document Number";

                                    This should not be so difficult.

                                            private void DocTrace_Load(object sender, EventArgs e)
                                            {
                                    // load dropdown options for comboboxedit
                                                cboFindOption.Properties.Items.AddRange(new string[] { "RM Document Number", "RM Audit Trail", "GL JE Number", "GL Audit Trail Code", "Posting Date" });

                                                cboFindOption.SelectedText = "RM Audit Trail";
                                                cboFindOption.SelectedIndex = 0;
                                                cboFindOption.EditValue = "RM Document Number";

                                    ...
                                    }

                                            private void cboFindOption_SelectedIndexChanged(object sender, EventArgs e)
                                            {
                                                if (cboFindOption.SelectedText == "Posting Date")
                                                {
                                                    dtePostingDate.Visible = true;
                                                    txtIDText.Visible = false;
                                                }
                                                else
                                    ...
                                    }

                                0

                                Hello,

                                Thank you for the question. You can assign the necessary value using the SelectedText, SelectedIndex or EditValue property. In your situation, you assign the EditValue property at the end, and as a result, exactly this value you see in the combo. Please use one of these properties to assign the value, and you'll get the correct result. I've attached a sample for you.

                                Thank you, Marina

                                Q234324.zip
                                0

                                Hi Marina
                                Please change your project as follows.
                                in every case, selected text is empty.

                                Habib
                                ---------------------------
                                          public Form1() {
                                               InitializeComponent();
                                               comboBoxEdit1.SelectedIndexChanged += new EventHandler(comboBoxEdit1_SelectedIndexChanged);
                                          }

                                          private void Form1_Load(object sender, EventArgs e) {
                                               // load dropdown options for comboboxedit

                                               comboBoxEdit1.Properties.Items.AddRange(new string[] { "RM Document Number", "RM Audit Trail", "GL JE Number", "GL Audit Trail Code", "Posting Date" });
                                            comboBoxEdit1.SelectedIndex = 0;
                                               comboBoxEdit1.SelectedText = "RM Audit Trail";

                                          }

                                          void comboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e) {
                                                MessageBox.Show(comboBoxEdit1.SelectedText);
                                               if(comboBoxEdit1.SelectedText == "Posting Date")
                                            {
                                                    //comboBoxEdit1.Visible = true;
                                                //txtIDText.Visible = false;
                                            }
                                            //else
                                          }

                                0

                                Hello,

                                I suggest to use the EditValue property rather than the SelectedText. I've modified my sample. However, I agree that this is an inconsistent behavior. We'll fix it ASAP(The ComboBoxEdit.SelectedText property isn't updated in the SelectedIndexChanged event handler)

                                	
                                [C#]
                                void comboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e) { MessageBox.Show( (sender as ComboBoxEdit).EditValue.ToString()); }

                                Thank you, Marina

                                Q234324.zip

                                To start a chat you should create a support ticket


                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners