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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Accessing the Selected Item Value in Databound Grid Combo

Thread ID:

Created:

Updated:

Platform:

Replies:

2655 Feb 6,2003 10:05 PM UTC Feb 8,2003 04:32 PM UTC WinForms 5
loading
Tags: GridControl
Anthony
Asked On February 6, 2003 10:05 PM UTC

I am stuggling with something that seems like it should be easy. I am trying to detect a change in a databound grid combobox cell, and then use the combobox selected value to set other controls on the form. The CurrentCellChanged event is firing based on the users selection, but the CellValue and Text properties of the current cell are not updated. I can press the save button on the form and query the underlying dataview and the data has been updated. Is there a different event I should be using? Here is a code sample: Private Sub dbgReviewApprove_CurrentCellValidated(ByVal sender As Object, ByVal e As System.EventArgs) Handles dbgReviewApprove.CurrentCellValidated Dim introw As Integer intRow = dbgReviewApprove.CurrentCell.RowIndex Select Case dbgReviewApprove.Item(introw, 7).CellValue Case 1, 3 Case 2 ' Change the Approval Date dbgReviewApprove.Item(introw, 6).Text = DateTime.Now.ToShortDateString End Select End Sub Thanks - Anthony

Administrator [Syncfusion]
Replied On February 6, 2003 10:25 PM UTC

Try CurrentCellAcceptedChanges. This is fired after the pending changes in the current cell have been transferred to the underlying cell. In CurrentCellAcceptedChanges you can get the cell value from the underlying cell. CurrentCellValidating is called before the changes are saved in the underlying cell that's why the .Cell Value returns the old value at that time. Stefan

Anthony
Replied On February 6, 2003 10:46 PM UTC

Stefan - Thanks for the response. CurrentCellAcceptedChanges was a step in the right direction. It does contain the updated values, but it does not appear to fire until the cell loses focus. When is the cell data actually updated? When the cell loses focus? Thanks - Anthony

Administrator [Syncfusion]
Replied On February 7, 2003 06:03 AM UTC

CurrentCellChanged and CurrentCellValidating are raised when changes were made in the current cell while in editing mode. At this time the cell value is only a temporary state of the edited cell. Before the cell value can be stored in the underlying cell it needs to be validated. This validation occurs when the user is satisfied with his text entry and ok's it. That's when CommitChanges is called which triggers CurrentCellValidating and after saving CurrentCellAcceptedChanges. You can force saving the data into the cell by explicitly calling CurrentCell.CommitChanges(). CommitChanges() will validate the cell contents and store the value in the cell style. The cell renderer will neither be deactivated nor loose focus. Another property you should look at is CurrentCell.Renderer.ControlValue. At the time CurrentCellChanged is raised the state of the current cells ControlValue is up to the specific cell editor. Most cells save the CurrentCell.ControlValue based on the current text before CurrentCellChanged is raised. But, it cannot be guaranteed that each cell renderer will do that. Most accurate is ControlText. It will return the text that is displayed in the cell but ControlValue must be explicitly generate by the renderer (and is only of use when you want to extend the cell type). We try to make all our cell editor do that and generate a CurrentCell.ControlValue before CurrentCellChanged when approbriate. If you are using the latest patch (I think 1.5.1.3 or higher) you should be able to access CurrentCell.ControlValue with a combobox and it should return the future cell value based on the text that is actually selected in the cell. Also, look for the CurrentCellClosedDropDown event. Stefan

Anthony
Replied On February 8, 2003 04:23 PM UTC

Stefan - Once again thank you for the response, but I am still confused. In your response you directed me to check the CurrentCell.ControlValue and CurrentCell.ControlText properties in the listed event procedures. When I do that, I get the message 'ControlText' is not a member of 'GridCurrentCell'. The type of the dbg.currentcell property is Syncfusion.Windows.Forms.Grid.GridCurrentCell. Should I be casting this to a different type to get at the properties you mentioned? In the end this is the approach that I took. In the CurrentCellCloseDropDown event, I called dbg.CommitChanges method which triggered the CurrentCellAcceptedChanges event. In the CurrentCellAcceptedChanges event I am able to get the correct value by using : dbg.Item(dbg.CurrentCell.RowIndex, dbg.CurrentCell.ColIndex).CellValue If there is a more efficient approach, or if this may present unforseen side effects. please let me know. Thanks again - Anthony Mansfield > CurrentCellChanged and CurrentCellValidating are raised when changes were made in the current cell while in editing mode. At this time the cell value is only a temporary state of the edited cell. Before the cell value can be stored in the underlying cell it needs to be validated. This validation occurs when the user is satisfied with his text entry and ok's it. That's when CommitChanges is called which triggers CurrentCellValidating and after saving CurrentCellAcceptedChanges. > > You can force saving the data into the cell by explicitly calling CurrentCell.CommitChanges(). CommitChanges() will validate the cell contents and store the value in the cell style. The cell renderer will neither be deactivated nor loose focus. > > Another property you should look at is CurrentCell.Renderer.ControlValue. At the time CurrentCellChanged is raised the state of the current cells ControlValue is up to the specific cell editor. Most cells save the CurrentCell.ControlValue based on the current text before CurrentCellChanged is raised. But, it cannot be guaranteed that each cell renderer will do that. Most accurate is ControlText. It will return the text that is displayed in the cell but ControlValue must be explicitly generate by the renderer (and is only of use when you want to extend the cell type). We try to make all our cell editor do that and generate a CurrentCell.ControlValue before CurrentCellChanged when approbriate. > > If you are using the latest patch (I think 1.5.1.3 or higher) you should be able to access CurrentCell.ControlValue with a combobox and it should return the future cell value based on the text that is actually selected in the cell. Also, look for the CurrentCellClosedDropDown event. > > Stefan >

Administrator [Syncfusion]
Replied On February 8, 2003 04:32 PM UTC

I think you should be fine with what you do now. I meant CurrentCell.Renderer.ControlText and CurrentCell.Renderer.ControlValue. Sorry about that mixup. Stefan

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;