We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

gdbg currency manager

hi, I used the version of syncfusion grid on a gdbg i used a combobox, and on the event GDBG.CurrentCellCloseDropDown I copied the values from the underliing dataview to the gdbg. All worked fine but then I updated to version and it does not work any more. When I put windows combobox on the form and bind it to the same source the currency mananager gives the right position, when I bind a textbox to the datasource it also works fine from the windows combobox but not from the gdbg combobox. Here is the code I use to read the currencymanager: Dim cmSource As CurrencyManager = CType(Me.BindingContext(Me.dvExtraItems), CurrencyManager) Dim drvSource As DataRowView = CType(cmSource.Current, DataRowView) Dim cmTarget As CurrencyManager = CType(Me.BindingContext(Me.dvBookingLineItems), CurrencyManager) Dim drvTarget As DataRowView = CType(cmTarget.Current, DataRowView) drvTarget("accountNumber") = drvSource("accountNumber") etc. GDBGBookingLineItems.Refresh() I think it has something to do with the bindin of the (syncfusion combobox style ) binding to the datasource kindly regards

9 Replies

AD Administrator Syncfusion Team June 17, 2004 10:27 AM UTC

You have to make sure you are using the same bindingcontext as the combobox is using. so, instead of Dim cmSource As CurrencyManager = CType(Me.BindingContext(Me.dvExtraItems), CurrencyManager) try something like this (assuming Me.dvExtraItems is set to be the StyleInfo.DataSource for this column). Dim bc as BindingContext = Me.grid.Model.CellModels("ComboBox").BindingContext Dim cmSource As CurrencyManager = CType(bc(Me.dvExtraItems), CurrencyManager) In, there was a problem where in some circumstances the BindingContext of a cell combobox was not being set early enough. Because of this problem, in 2.0, the grid makes sure the BindingContext is set by forcing it to a new BindingContext in these situations. This means that if you want other controls on the form to be in sync with the grid''s embedded combobox, you must somehow ensure they are all using the same BindingContext. If this does not work, if you can post a sample project showing the problem, maybe we can spot the problem.

LT Lucas Tijssen June 18, 2004 05:53 AM UTC

thanks for the effort, i sincerily hope you can help me on this one. I tried to make a small version around the problem. kindly regards gdbg_1134.zip gdbg_5518.zip

AD Administrator Syncfusion Team June 18, 2004 07:53 AM UTC

You can use this code to get the DataRowView you want. Dim cr As GridComboBoxCellRenderer = Me.GDBG1.CurrentCell.Renderer Dim drvSource As DataRowView = Me.dvExtraItems(cr.ListBoxPart.SelectedIndex) MsgBox("value of the selectedindex = " & cr.ListBoxPart.SelectedIndex & vbCrLf & _ "the value of itemDescription = " & drvSource("itemDescription"))

LT Lucas Tijssen June 18, 2004 08:37 AM UTC

thank you, it works, but when I use the combobox the grid does not insert a new row ?! so writing the new values gives an error. Index 0 is not non-negative and below total rows count.

AD Administrator Syncfusion Team June 18, 2004 09:23 AM UTC

How do I see this problem in your sample?

LT Lucas Tijssen June 18, 2004 09:33 AM UTC

if I use the combobox I get the error. When I first make a couple of datarows in the table it works fine. Selecting a value from the combobox should work the same as typing in a cell, making a new row in de dataview. gdbg_2204.zip

AD Administrator Syncfusion Team June 18, 2004 10:15 AM UTC

By default, changes to a row in the grid (and even a new row being added) are not pushed to the datasource until you leave the row. This is why the row is not there when you are trying to use it in your FillDataRow method. You can force the grid to commit the changes at the top of your FillDataRow method so they will be available in the DataSource for you to use at that point. You can do this by adding these lines at the top of that method. Me.GDBG1.CurrentCell.ConfirmChanges() Me.GDBG1.Binder.EndEdit() One other comment on what happens when you do this. You will notice the grid looks like it adds one extra row and then removes it. You can avoid this flash by changing this grid property. Me.GDBG1.CurrentCell.ConfirmChanges(). This is set to true by default in the designer generated code. I think setting it false will avoid the extra row flash. Me.GDBG1.OptimizeInsertRemoveCells = False

AD Administrator Syncfusion Team June 21, 2004 04:00 AM UTC

sorry Clay but that does not solve my problem. As far as I can see is the cause of the problem that when I click the combobox in a empty row it is not recognised as an insert in the grid. when I click in another cell in an empty row as soon as I use a key there is an row inserted in the grid. When I use this way to create some rows in the grid, I can afterwards use the combobox to change the content of the row. kindly regards.

AD Administrator Syncfusion Team June 21, 2004 04:14 AM UTC

Sorry, I put the lines in the combobox event and now it works fine Private Sub grid_SelectionChanged(ByVal sender As System.Object, _ ByVal e As Syncfusion.Windows.Forms.PopupClosedEventArgs) Handles GDBG1.CurrentCellCloseDropDown ''copies values from dvExtraitems to InvoiceLineItems Me.GDBG1.CurrentCell.ConfirmChanges() Me.GDBG1.Binder.EndEdit() thanks

Live Chat Icon For mobile
Up arrow icon