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

GridCombobox

We have a custom class for combobox where we filter the datasource in relation of the precedent cell in a row. If I use the mouse to select a value, every things work. But if I use the keyboard to type a value, the filter on the datasource seem to be diseabled? Any suggestions? Private Sub gridFavoris_CurrentCellActivated(ByVal sender As Object, ByVal e As System.EventArgs) Try Dim cc As GridCurrentCell = Grid.CurrentCell Dim cr As GridDropDownGridListControlCellRenderer = cc.Renderer Dim strIDProjet As String If cc.ColIndex = COL_TACHE Then Dim dv As New DataView(dtTaches) strIDProjet = _gridFavoris(cc.RowIndex, COL_PROJET).CellValue If strIDProjet = "" Then strIDProjet = "-1" dv.RowFilter = String.Format("[IDProjet] = ''{0}''", strIDProjet) CType(cr.ListControlPart, GridDropDownGridListControlPart).DataSource = dv Debug.WriteLine("Filtre = " & strIDProjet & " reset") cc.ShowDropDown() End If Catch ex As Exception ''Afficher dans event log. End Try End Sub

15 Replies

AD Administrator Syncfusion Team November 29, 2005 03:33 PM UTC

Try setting setting e.Style.DataSource in QueryCellInfo to be the dataview instead of in CUrrentCellActivating. You can check e.ColIndex = COL_TACHE and e.RowIndex > 0 before trying to set DataSource. If you are using a GridDataBoundGrid, the event is grid.Model.QueryCellInfo and you have to use AddHandler to subscribe to it.


FO Francis Ouellet November 29, 2005 03:48 PM UTC

Hi clay, I send you my class for these combobox. I can''t find where I have to add the AddHandler for QueryCellInfo. Thanks >Try setting setting e.Style.DataSource in QueryCellInfo to be the dataview instead of in CUrrentCellActivating. You can check e.ColIndex = COL_TACHE and e.RowIndex > 0 before trying to set DataSource. > >If you are using a GridDataBoundGrid, the event is grid.Model.QueryCellInfo and you have to use AddHandler to subscribe to it.

GridFavoris.zip


AD Administrator Syncfusion Team November 29, 2005 04:47 PM UTC

Instead of: AddHandler grid.CurrentCellActivated, AddressOf gridFavoris_CurrentCellActivated you can try AddHandler grid.Model.QueryCellInfo, AddressOf gridFavoris_QueryCellInfo adding the code for the gridFavoris_QueryCellInfo method.


FO Francis Ouellet November 29, 2005 06:39 PM UTC

Hi Clay, I have added AddHandler grid.Model.QueryCellInfo, AddressOf gridFavoris_QueryCellInfo with this event Private Sub gridFavoris_QueryCellInfo(ByVal sender As Object, ByVal e As Syncfusion.windows.Forms.grid.GridQueryCellInfoEventArgs) Try Dim cc As GridCurrentCell = Grid.CurrentCell Dim cr As GridDropDownGridListControlCellRenderer = cc.Renderer Dim strIDProjet As String If cc.ColIndex = COL_TACHE Then Dim dv As New DataView(dtTaches) strIDProjet = _gridFavoris(cc.RowIndex, COL_PROJET).CellValue If strIDProjet = "" Then strIDProjet = "-1" dv.RowFilter = String.Format("[IDProjet] = ''{0}''", strIDProjet) CType(cr.ListControlPart, GridDropDownGridListControlPart).DataSource = dv '' cc.ShowDropDown() End If Catch ex As Exception Debug.WriteLine(ex.ToString) ''Afficher dans event log. End Try End Sub And I''m getting this error when I make a selection in the list : System.InvalidOperationException: Recursive call detected. When accessing grid cell objects from a QueryCellInfo event handler make sure you do not recursively access the same cell. at Syncfusion.Windows.Forms.Grid.GridModel.GetCellInfo(Int32 rowIndex, Int32 colIndex, GridStyleInfo style) at Syncfusion.Windows.Forms.Grid.GridModel.Syncfusion.Windows.Forms.Grid.IGridVolatileDataContainer.GetCellInfo(Int32 rowIndex, Int32 colIndex, GridStyleInfo style) at Syncfusion.Windows.Forms.Grid.GridVolatileData.get_Item(Int32 rowIndex, Int32 colIndex) at Syncfusion.Windows.Forms.Grid.GridModel.get_Item(Int32 rowIndex, Int32 colIndex) at Syncfusion.Windows.Forms.Grid.GridControl.get_Item(Int32 rowIndex, Int32 colIndex) at FeuilleTemps.GridFavorisCellRenderer.gridFavoris_QueryCellInfo(Object sender, GridQueryCellInfoEventArgs e) in H:\Programmation\Dossiers_Courants\!!Implantation project\!Feuille de temps 2.1.1 QueryCellInfo\GridFavoris.vb:line 51


AD Administrator Syncfusion Team November 29, 2005 06:45 PM UTC

Try this code:
Private Sub gridFavoris_QueryCellInfo(ByVal sender As Object, ByVal e As Syncfusion.windows.Forms.grid.GridQueryCellInfoEventArgs)
Try


If e.ColIndex = COL_TACHE AndAlso e.RowIndex > 0 Then
	Dim cr As GridDropDownGridListControlCellRenderer = _gridFavoris.CellRenderers("GridListControl")
	Dim strIDProjet As String
	Dim dv As New DataView(dtTaches)
	strIDProjet = _gridFavoris(e.RowIndex, COL_PROJET).CellValue
	If strIDProjet = "" Then strIDProjet = "-1"
	dv.RowFilter = String.Format("[IDProjet] = ''''{0}''''", strIDProjet)
	CType(cr.ListControlPart, GridDropDownGridListControlPart).DataSource = dv
End If
Catch ex As Exception
	Debug.WriteLine(ex.ToString)
''''Afficher dans event log.
End Try
End Sub


FO Francis Ouellet November 29, 2005 07:05 PM UTC

Hi again, If I change these line Dim cc As GridCurrentCell = Grid.CurrentCell Dim cr As GridDropDownGridListControlCellRenderer = cc.Renderer for Dim cr As GridDropDownGridListControlCellRenderer = _gridFavoris.CellRenderers("GridListControl"), I''m changing the datasource of witch cell?


AD Administrator Syncfusion Team November 29, 2005 11:20 PM UTC

You are changing the data source for the cell at (e.RowIndex , e.ColIndex) where: e.ColIndex = COL_TACHE AndAlso e.RowIndex > 1


FO Francis Ouellet December 1, 2005 03:21 PM UTC

Hi Clay, My code look like this : Private Sub gridFavoris_QueryCellInfo(ByVal sender As Object, ByVal e As Syncfusion.windows.Forms.grid.GridQueryCellInfoEventArgs) Try If e.ColIndex = COL_TACHE AndAlso e.RowIndex > 0 Then Dim strIDProjet As String strIDProjet = _gridFavoris(e.RowIndex, COL_PROJET).CellValue If strIDProjet = "" Or strIDProjet = "-1" Then Exit Sub Dim dv As New DataView(dtTaches) dv.RowFilter = String.Format("[IDProjet] = ''{0}''", strIDProjet) Dim cr As GridDropDownGridListControlCellRenderer = _gridFavoris.CellRenderers("GridListControl") CType(cr.ListControlPart, GridDropDownGridListControlPart).DataSource = dv Debug.WriteLine("Filter = " & strIDProjet) End If Catch ex As Exception Debug.WriteLine(ex.ToString) End Try End Sub The event is raised but when I dropdown the combobox, the datasource was not changed. It''s why I ask you about wich cell was changed.


AD Administrator Syncfusion Team December 1, 2005 03:32 PM UTC

Can you upload a sample project showing the problem?


FO Francis Ouellet December 1, 2005 04:24 PM UTC

Voilà! Do you want my data?

TestFavoris.zip


AD Administrator Syncfusion Team December 1, 2005 04:47 PM UTC

To be of help, I need a sample I can run and debug, so yes I will need some data. Any chance you could hack the sample to load the data using DataSet.ReadXml. On your system where you have access to your sql db, after you have read the data into the datatables you are using, you can add a couple of lines of code to add these tables to a DataSet, and then use use DataSet.WriteXml to write the sample data as an xml file. Then once you have the XML file with teh data in it, in the sample you can comment out the code that you are now using to fill the datatables through sql, and instead just do a DatSet.ReadXml to load the data.


FO Francis Ouellet December 1, 2005 07:39 PM UTC

I''have made it with access. Simplier for me.

TestFavoris0.zip


AD Administrator Syncfusion Team December 2, 2005 01:12 AM UTC

Thank you. I can run your project now. You said the program behaves differently if you use the mouse to choose values in the comboboxes than when you use the keyboard. I tried first using the mouse in one row. Then I went to another row and used the keyboard to select the same values, but I could not really notice any difference. Exactly what steps do I take to see the problem you are having.


FO Francis Ouellet December 2, 2005 03:30 PM UTC

Hi Clay, If you type in the first col 015404-5 you''re suppose to have only one choice 01.1 in the second col. If 030169 in first col = two choice 01.1 and 02.1 in the second col. The second col is suppose to be filtered by the value in the first col.


AD Administrator Syncfusion Team December 2, 2005 04:28 PM UTC

I think your sample is working now. The change was to set the DataSource of the 2nd column combobox to be the defaultview of the datatable. And, then in QueryCellInfo, just apply the filter to this defaultview without creating a new DataView. http://www.syncfusion.com/Support/user/uploads/TestFavoris_385204e4.zip

Loader.
Live Chat Icon For mobile
Up arrow icon