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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

CloseDropDown event in GridControl

Thread ID:

Created:

Updated:

Platform:

Replies:

3214 Mar 8,2003 04:08 PM UTC Feb 17,2005 10:00 PM UTC WinForms 13
loading
Tags: GridControl
Jamie Hill
Asked On March 8, 2003 04:08 PM UTC

I seem to be having a problem changing the selected index of a combobox in my grid. The CloseDropDown event fires, but the PopupCloseType (readonly) is always set to cancel. How can I either change the close type? Is there a workaround for this? Thanks, JH

Administrator [Syncfusion]
Replied On March 8, 2003 08:08 PM UTC

I am not sure I understand your question fully. Sorry if I don't. If this is CellType = "ComboBox", then once the combobox closes, the list part is no longer availabel, so trying to set its selected index is not appropriate. After the combobox closes, you can change the Control.Text property of the cell renderer to modify the value. Below is a little snippet that changes a slected "two" to "three".
private void gridControl1_CurrentCellCloseDropDown(object sender, PopupClosedEventArgs args)
{
	GridCurrentCell cc = this.gridControl1.CurrentCell;
	if(cc.Renderer.ControlText == "two")
		cc.Renderer.Control.Text = "three";
}

Jamie Hill
Replied On March 10, 2003 06:12 PM UTC

Hi Clay, Sorry if I wasn't clear enough. I have done some more testing and might be able to make it a little clearer. I have a grid where based upon validation a cell could be changed to a bound list of possible choices. If there is an exact match in the database, the cell is left as a textbox. If there are multiple possible matches, the cell is changed to a combobox and the box is bound to the datatable returned. It turns out that most of the comboboxes behave normally. The ones that are causing problems are the comboboxes in the row after a textbox. In the sample data below, I would be having a problem with row #3. What happens is that when the item is selected from the list, it appears to retain the selection. However, when the cell loses focus, the selection is reset to the first item in the list. The combobox in rows 4, 5 and 6 would behave properly. Sample Data: Row # Cell Type 1 textbox 2 textbox 3 combobox 4 combobox 5 combobox 6 combobox 7 textbox I tried putting a messagebox in the CloseDropDown event to see if the ID was coming through, but it would always give me the ID of the first item in the list. This is a very strange problem that I am having. I tried recreating it with another project, but I have not been able to. I have attached a sample file that shows how I am adding these rows to the grid.

Administrator [Syncfusion]
Replied On March 11, 2003 06:51 AM UTC

Here is something that is quick to try to see if it will handle this problem. In your CurrentCloseDropDown handler, add this line to force the value to be placed into grid storage so you can later get it using indexers. While a cell is actively being edited, you cannot get its value by indexing the grid. dgCleaned.CurrentCell.ConfirmChanges(False) If this does not help, exactly where is your ValidateCurrentRow being called from?

Jamie Hill
Replied On March 19, 2003 05:50 PM UTC

ValidateCurrentRow is called from a button click. It loops through the rows in the grid and validates each row using the ValidateCurrentRow method.

Administrator [Syncfusion]
Replied On March 19, 2003 07:32 PM UTC

I don't really have any further insight. If you own the source code version of the grid, you can step down into the grid code to see why things are not working. If you like, you can create a Direct Trac incident and attached your project showing the problem. If we can compile it and see the problem, then we can try to come up with a resolution.

Philip Bishop
Replied On February 1, 2005 04:35 PM UTC

So does this mean that in the currentcelldropdown i cant get at the index of the seleceted item in my list? I have 2 drop down cols right next to each other. when the user selects an item in the first dropdown i want the next cols dropdow in the same rame to go to that same index. Is this possible. Like if you had both drop downs populated with the same data and they selected the 8th one in the first drop down i want it to go to the same 8th one in the next drop down??

Administrator [Syncfusion]
Replied On February 2, 2005 11:03 AM UTC

Phil, In order to get the index of a selected item in your list you can call (GridComboBoxCellModel) CurrentCell.Renderer.Model).FindValue passing in the CurrentCell.Renderer.ControlValue as argument. Stefan

Philip Bishop
Replied On February 2, 2005 12:55 PM UTC

Im not for sure i understand what you said i should do. I cant seem to make that work. I dont know what im missing. I''ve tried to do what you said in our live project and cant get it to work. I''m attaching a little sample project. Can you show me how in the closedropdown after they select a value in col2 to make that same value show up in col3 in the same row. Thanks Ok it wouldnt let me upload and it finally would so you are going to get an email you can disregard choicelist1_7563.zip

Administrator [Syncfusion]
Replied On February 2, 2005 02:15 PM UTC

Hi Phil, Set Me.grdDateRange.ColCount = 5 then you can do this: Private Sub grdDateRange_CurrentCellCloseDropDown(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.PopupClosedEventArgs) Handles grdDateRange.CurrentCellCloseDropDown Dim grid As GridControlBase = sender Dim cb As GridComboBoxCellRenderer = CType(grid.CurrentCell.Renderer, GridComboBoxCellRenderer) Dim controlText As String Dim controlValue As Object If Not cb Is Nothing Then controlText = cb.ControlText controlValue = cb.ControlValue grid.Model(grid.CurrentCell.RowIndex, 3).Text = controlText grid.Model(grid.CurrentCell.RowIndex, 4).CellValue = controlValue Dim n As Integer n = cb.Model.FindValue(grid.Model(grid.CurrentCell.RowIndex, grid.CurrentCell.ColIndex), controlValue) grid.Model(grid.CurrentCell.RowIndex, 5).CellValue = n End If End Sub it will show you the index in column 5. Stefan

Philip Bishop
Replied On February 2, 2005 04:18 PM UTC

Thanks. Now I totally understand it. Works just how i wanted it.

Administrator [Syncfusion]
Replied On February 17, 2005 09:53 PM UTC

Ok i thought i had this all understood but i guess i have one more question. say when i im in the currentcellclosedropdown for a cell in col2. i know how to get the index from what you showed me for that cell in that col, but can i also get the index from a cell in the same row but in col3 at the same time?

Administrator [Syncfusion]
Replied On February 17, 2005 09:58 PM UTC

one last thing that may help you understand what im trying to do. if they select a value in col2 from a drop down i want it to fill in the col3 drop down with the same data IF ITS BLANK. Also if they fill in col2 with data and col3 already has data but is less then col2 then i want to set col3 with col2 data. col3 drop down index can never be less then col2 drop down index

Administrator [Syncfusion]
Replied On February 17, 2005 10:00 PM UTC

ok you can just disregard this because my brain finally started functioning properly and i figured out what i was doing.

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

;