March 8, 2003 03:08 PM
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";
March 10, 2003 01:12 PM
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.
Row # Cell Type
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.
March 11, 2003 01:51 AM
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.
If this does not help, exactly where is your ValidateCurrentRow being called from?
March 19, 2003 12:50 PM
ValidateCurrentRow is called from a button click. It loops through the rows in the grid and validates each row using the ValidateCurrentRow method.
March 19, 2003 02:32 PM
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.
February 1, 2005 11:35 AM
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??
February 2, 2005 06:03 AM
In order to get the index of a selected item in your list you can call
passing in the CurrentCell.Renderer.ControlValue as argument.
February 2, 2005 07:55 AM
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
February 2, 2005 09:15 AM
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
it will show you the index in column 5.
February 2, 2005 11:18 AM
Thanks. Now I totally understand it. Works just how i wanted it.
February 17, 2005 04:53 PM
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?
February 17, 2005 04:58 PM
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
February 17, 2005 05:00 PM
ok you can just disregard this because my brain finally started functioning properly and i figured out what i was doing.