Home › Forums › WinForms controls › Xceed Grid for WinForms › Problems with Combox
-
AuthorPosts
-
#17673 |
I know I have to be doing something wrong but just can’t find the issue. I am using v3.9 of the .Net Grid.
Problem: When the grid is displayed in the form, the combobox column is displaying the value of the column from the binding dataset for the grid. When I click on the cell, the combox displays the appropriate caption information. But when I move off the cell, the value either becomes empty or returns to the original value of the row from the binding dataset.
The dataset contains multiple datatables without any relations established. The grid is bound to one of the datatables and the combobox is bound to a different datatable.
The key value for the combo box is a string value (Alpha-Numeric). Not a typical numeric Id value showing a string Caption.
What is going wrong?
Here is my code:
‘Set the Grid Properties
grdExportDetails.Enabled = True
grdExportDetails.BeginInit()
‘Datasource
grdExportDetails.SetDataBinding(dsExportDetails, “ProgramBase”)
‘Headers
grdExportDetails.HeaderRows.Add(columnManagerRow)
grdExportDetails.Columns(“ProgramId”).Visible = False
grdExportDetails.Columns(“PackageId”).Visible = False
‘Editing with single click
grdExportDetails.SingleClickEdit = True
‘Checkbox column
grdExportDetails.Columns(“Selected”).VisibleIndex = 0
grdExportDetails.Columns(“Selected”).Width = 50
grdExportDetails.Columns(“Selected”).CellEditorManager = New CheckBoxEditor()
grdExportDetails.Columns(“Selected”).CellViewerManager = New CheckBoxViewer()
grdExportDetails.Columns(“Selected”).HorizontalAlignment = HorizontalAlignment.Center
grdExportDetails.Columns(“Selected”).VerticalAlignment = VerticalAlignment.Center
‘Dropdown columns
‘Currency
CurrencyComboBoxEditor = New ComboBoxEditor(dsExportDetails, “ExchangeRates”, “ExchangeSetName”, “%RateDescriptor%”)
CurrencyComboBoxEditor.TemplateControl.AllowDropDown = True
CurrencyComboBoxEditor.TemplateControl.AllowFreeText = False
grdExportDetails.Columns(“ProgBaseCurrency”).CellEditorManager = CurrencyComboBoxEditor
grdExportDetails.Columns(“ProgBaseCurrency”).HorizontalAlignment = HorizontalAlignment.Left
‘Readonly the other columns
grdExportDetails.Columns(“ProgBaseWeight”).ReadOnly = True
grdExportDetails.Columns(“ProgBaseDistance”).ReadOnly = True
grdExportDetails.Columns(“ProgBaseEnergy”).ReadOnly = True
grdExportDetails.Columns(“Idnum”).ReadOnly = True
grdExportDetails.EndInit()
Imported from legacy forums. Posted by Emerson (had 4535 views)
Hi Emerson,
You will need to set the binding for the
CellViewerManager. As I can see from your code, you are not doing this.
Try doing the following:Visual Basic
——————-grdExportDetails.Columns(“Selected”).CellViewerManager = New
CheckBoxViewer(dsExportDetails, “ExchangeRates”, “ExchangeSetName”,
“%RateDescriptor%”)
——————-This should solve the issue as to why you cannot see the value stay at the one that is chosen.
Imported from legacy forums. Posted by Marc [Xceed] (had 310 views)
Thanks for the reply but the problem is with the Combobox and not the checkbox. The checkbox works just fine.
As for setting the CellViewerManager for the Combobox, I try to do that and I get an error indicating that the Key value – blah blah has already been loaded into some dictionary.
Imported from legacy forums. Posted by Emerson (had 411 views)
Additionally, the initial displayed value in the column with the combobox is the value member and not the display member.
Imported from legacy forums. Posted by Emerson (had 388 views)
Hi Emerson,
Are you able to send me a small self-contained sample application so that way I can investigate the issue? With this information, I will be able to provide you with an answer.
Imported from legacy forums. Posted by Marc [Xceed] (had 357 views)
I can send you the application but I am not going to be able to provide any kind of data container for you to use. Where do I send this?
Imported from legacy forums. Posted by Emerson (had 421 views)
Hi Emerson,
is it possible to recreate the issue with dummy data?
Imported from legacy forums. Posted by Marc [Xceed] (had 327 views)
I’m not sure how to create a sample app that has self contained data not coming from a database. Seems kind of funny to me that in all my years of programming I have never needed to anything like that.
I guess thinking about it, I would just need to code the building of the dataset and tables manually. Any suggestions on other easier, quicker ways would be appreciated.
Imported from legacy forums. Posted by Emerson (had 360 views)
Hi Emerson,
I have attached a small sample to get you started… Let me know if you can reproduce it. I will continue to investigate the issue.
Imported from legacy forums. Posted by Marc [Xceed] (had 334 views)
Marc,
How do I upload a zip file when I have it ready?
I do not see any option within my browser when replying to the post to do so.
Thanks.
Imported from legacy forums. Posted by Emerson (had 351 views)
Hi Emerson,
When you reply to this forum post, there is an ‘Options’ tab right about the text box. Click on it and you should see that you can add an attachment.
Imported from legacy forums. Posted by Marc [Xceed] (had 331 views)
Marc,
Attached is sample project replicating the error that I get using the CellViewManager, not being able to see the RateDescriptor value in the column instead of the Id value of CURRDOL and the ComboxBox selection not being saved when changed.
Thanks.
Imported from legacy forums. Posted by Emerson (had 370 views)
Hi Emerson,
I believe the code is fine. I had just noticed that with the data you had, I couldn’t tell which one was which because I was only seeing the ID (which were all the same in the dummy data). I have re-attached the sample and as you can see it works.
Imported from legacy forums. Posted by Marc [Xceed] (had 336 views)
Marc,
The data sample I sent to you was exactly what is going to be received for consumption by the grid. Changing the sample data does not resolve the issue.
To give you a bit more of an idea of what needs to be done, I have attached an Excel worksheet with a sample of the actual ExchangeRates structure with the data anonymized.
The key value for each facility linking to the ExchangeRates structure is the ExchangeSetName. Just happens to be a String and not an integer value. Each ExchangeSetName has N number of RateDescriptors describing the value contained in the Rate column.
The user is being shown the RateDescriptor values in the combo box that are available for each facilities ExchangeSetName. After the selection of the desired RateDescriptor by the user, a currency conversion process will take place using the Rate value for the selected RateDescriptor within the facilities ExchangeSetName.
I hope this helps because we can not change the data to make the ComboBox work in the grid.
Imported from legacy forums. Posted by Emerson (had 738 views)
Marc,
Now that I have had the weekend to review everything again, I believe there may be room for manipulation of the data columns into a more standard lookup style format utilizing the Id column within the data.
Let me try a few things and will post back the results later today or tomorrow.
Imported from legacy forums. Posted by Emerson (had 765 views)
-
AuthorPosts
- You must be logged in to reply to this topic.