Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                0

                                Hi Alexander,

                                Thank you for the message.

                                It seems we already answered a similar question. Please review the Binding an enum object to a ComboboxEdit or a LookupEdit thread. Please let me know if you need any further assistance.

                                Thanks,
                                Svetlana

                                0

                                Hi Svetlana,

                                The question is not to bind just an enum. The question is how to bind an enum with descriptions ("description" is the key word here; please see the very beginning of the codeproject's article).

                                My enum looks like the following:
                                     public enum ArchPeriod
                                     {
                                          [EnumDescription("Сутки")]
                                          Today,

                                          [EnumDescription("3 дня")]
                                          Last3Days,

                                          [EnumDescription("7 дней")]
                                          Last7Days,

                                          [EnumDescription("Месяц")]
                                          Month,

                                          [EnumDescription("Период...")]
                                          Period,
                                     }

                                Notice the localized enum descriptions.
                                This is how I bind the standard ComboBox:
                                               comboBox1.DataSource = typeof(ArchPeriod).ToList();
                                               comboBox1.DisplayMember = "Value";
                                               comboBox1.ValueMember = "Key";

                                This is how I bind Xtra ImageComboBoxEdit:
                                               imageComboBoxEdit1.Properties.Items.AddEnum(typeof(ArchPeriod));

                                The result is in the screenshot attached (1 - standard; 2 - extra).
                                See the difference?

                                0

                                Also I would like to be able to bind it to a) standalone combobox and b) combo repository in a grid.
                                Is it possible?

                                Thanks!

                                0

                                Please give us additional time. We'll answer you ASAP.

                                0

                                Hi Alexander,

                                Thank you for the additional clarification. It was very useful.

                                Please note that our ComboBoxEdit doesn't contain the DataSource, ValueMember, DisplayMember properties. You can populate it by setting the ComboBoxEdit.Properties.Items property. So, in your case it's better to use the LookUpEdit (please review the property's description for more information) rather than the ComboBoxEdit. Set the LookUpEdit.Properties.DataSource, LookUpEdit.Properties.ValueMember and LookUpEdit.Properties.DisplayMember properties in the same manner as for the standard ComboBox.
                                 
                                I've prepared a sample demonstrating how to use the LookUpEdit and RepositoryItemLookUpEdit. Please review the attached project and let me know if the proposed solution is suitable.

                                Thanks,
                                Svetlana

                                0

                                Thanks a lot for the support! It is what I need.

                                0

                                Hi again,

                                Your sample project worked fine, until I tried to bind it to DataTable.
                                The enum is bound successfully, but when a row is not selected, it displays the empty string.
                                I have modified your project to illustrate the problem (see attached).
                                Can you please help me to solve this?

                                0

                                Hi Alexander,

                                Thank you for the feedback.

                                The easiest solution is to change the DataColumn.DataType to Object. I've modified the previous sample based on your requirements, and now it works as expected here. Please refer to the attached project, and let me know if this solution is suitable.

                                Thanks,
                                Svetlana

                                0

                                Hi Svetlana,

                                Thanks for the reply!

                                What are other solutions?
                                I don't like this one, since it requires a modification of DataTable/DataSet loaded from XML file or database.
                                Modifying a data source in order to be able to show it in a grid doesn't seem logical to me. Also it makes it impossible to check column's type after the modification.

                                /BR, Alexander

                                0

                                Moreover I get the following exception if I try to change column type after DataSet/DataTable filled with data from the source.

                                An unhandled exception of type 'System.ArgumentException' occurred in System.Data.dll

                                Additional information: Cannot change DataType of a column once it has data.

                                0

                                Please give us additional time. We'll answer you ASAP.

                                0

                                Hi Alexander,

                                Thank you for the feedback.

                                Here are my comments to your questions:

                                >What are other solutions?

                                I'm afraid there are no other solution to this issue. It's caused by the fact that the editor's data type is "object {WindowsFormsApplication102.SimpleEnum}". So, it's necessary to modify the corresponding data column type to object.

                                >Moreover I get the following exception if I try to change column type after DataSet/DataTable filled with data from the source.

                                You should first create the DataColumn, set the DataColumn.DataType property to object. Then, add it to the data table. Please review the project attached previously. It works as expected here.
                                If it doesn't help you, please modify my sample to replicate this issue. We'll examine it, and do our best to help you overcome this shortcoming.

                                Thanks,
                                Svetlana

                                0

                                Please find the project attached.
                                Grid control is bound to DataTable in the typed DataSet read from XML file.

                                I don't want to change column's type in the DataSet and I would like to bind it to table having drop-down list with enum descriptions in the corresponding column.

                                0

                                Hi Alexander,

                                Thank you for the attached project. It was very useful.

                                Please note that changing the column's DataType property after populating the corresponding data table isn't the correct approach (as a result, the System.ArgumentException is raised). You can accomplish this task by changing the column's DataType property in the DataSet without any problems. However, as I understand it, doesn't meet your requirements. As an alternative solution to this issue I can suggest that you do the following: create an unbound column (set its GridColumn.UnboundType property to object) and handle the GridView.CustomUnboundColumnData event to populate, based on data of the "DataColumn2" column. Furthermore, hide the "DataColumn2" column by setting its Visible property to false.

                                I've modified your project accordingly. Please review the attached project, and let me know if this solution makes sense.

                                Thanks,
                                Svetlana

                                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