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.
Unfortunately, activation email could not send to your email. Please try again.

GridCombobox

Thread ID:

Created:

Updated:

Platform:

Replies:

37729 Nov 29,2005 09:55 AM Dec 2,2005 11:28 AM Windows Forms 15
loading
Tags: GridControl
Francis Ouellet
Asked On November 29, 2005 09:55 AM

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

Administrator [Syncfusion]
Replied On November 29, 2005 10:33 AM

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.

Francis Ouellet
Replied On November 29, 2005 10:48 AM

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

Administrator [Syncfusion]
Replied On November 29, 2005 11:47 AM

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.

Francis Ouellet
Replied On November 29, 2005 01:39 PM

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

Administrator [Syncfusion]
Replied On November 29, 2005 01:45 PM

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

Francis Ouellet
Replied On November 29, 2005 02:05 PM

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?

Administrator [Syncfusion]
Replied On November 29, 2005 06:20 PM

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

Francis Ouellet
Replied On December 1, 2005 10:21 AM

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.

Administrator [Syncfusion]
Replied On December 1, 2005 10:32 AM

Can you upload a sample project showing the problem?

Francis Ouellet
Replied On December 1, 2005 11:24 AM

Voilà! Do you want my data?

TestFavoris.zip

Administrator [Syncfusion]
Replied On December 1, 2005 11:47 AM

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.

Francis Ouellet
Replied On December 1, 2005 02:39 PM

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

TestFavoris0.zip

Administrator [Syncfusion]
Replied On December 1, 2005 08:12 PM

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.

Francis Ouellet
Replied On December 2, 2005 10:30 AM

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.

Administrator [Syncfusion]
Replied On December 2, 2005 11:28 AM

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

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.

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.

;