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

GGC filterbar using textboxes

Thread ID:





48988 Sep 7,2006 05:30 PM UTC Sep 9,2006 09:24 AM UTC WinForms 2
Tags: GridControl
Administrator [Syncfusion]
Asked On September 7, 2006 05:30 PM UTC

I use this code, posted in this forum.
My problem is that the gridGrouping Control does not refresh the displayed data when i delete the text from the textbox filter.
This happens only If the column contains empty cells. If all the cells of the column contain data, then everything is OK. Can anybody give me a tip on this?


Here is the code:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

AddHandler Me.GridGroupingControl1.TableControlCurrentCellChanged, AddressOf gridGroupingControl1_TableControlCurrentCellChanged
AddHandler Me.GridGroupingControl1.TableControlCurrentCellActivating, AddressOf gridGroupingControl1_TableControlCurrentCellActivating
AddHandler Me.GridGroupingControl1.QueryCellStyleInfo, AddressOf gridGroupingControl1_QueryCellStyleInfo
Me.GridGroupingControl1.TableDescriptor.Columns("columnXXX").AllowFilter = True
Me.GridGroupingControl1.TableDescriptor.Columns("columnXXX").Appearance.FilterBarCell.CellType = "TextBox"

End Sub

#Region "Grid Grouping Control TEXTBOX FilterBar code"

Sub gridGroupingControl1_TableControlCurrentCellActivating(ByVal sender As Object, ByVal e As GridTableControlCurrentCellActivatingEventArgs)
Dim style As GridTableCellStyleInfo = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex)
If TypeOf style.TableCellIdentity.DisplayElement Is GridFilterBarRow Then
e.Inner.Cancel = Not (e.TableControl.Table.CurrentRecordManager.CurrentElement Is Nothing)
End If
End Sub

Private filterValues As Hashtable = New Hashtable

Private Sub gridGroupingControl1_TableControlCurrentCellChanged(ByVal sender As Object, ByVal e As GridTableControlEventArgs)
Dim cc As GridCurrentCell = e.TableControl.CurrentCell
Dim style As GridTableCellStyleInfo = e.TableControl.GetTableViewStyleInfo(cc.RowIndex, cc.ColIndex)
If TypeOf style.TableCellIdentity.DisplayElement Is GridFilterBarRow Then
Dim rowIndex As Integer = Me.GridGroupingControl1.Table.DisplayElements.IndexOf(style.TableCellIdentity.DisplayElement)
Dim colIndex As Integer = cc.ColIndex
Dim colName As String = style.TableCellIdentity.Column.Name
Dim expression As String = String.Format("[{0}] LIKE ''{1}*''", colName, cc.Renderer.ControlText)

If style.TableCellIdentity.Table.TableDescriptor.RecordFilters(colName) Is Nothing Then
style.TableCellIdentity.Table.TableDescriptor.RecordFilters.Add(New RecordFilterDescriptor(colName, expression))
filterValues.Add(colName, cc.Renderer.ControlText)
style.TableCellIdentity.Table.TableDescriptor.RecordFilters(colName).Expression = expression
filterValues(colName) = cc.Renderer.ControlText
If cc.Renderer.ControlText = Nothing Then
End If
End If
CType(sender, GridGroupingControl).Update()
End If
End Sub

Private Sub gridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As GridTableCellStyleInfoEventArgs)
If e.TableCellIdentity.TableCellType = GridTableCellType.FilterBarCell AndAlso Not (e.TableCellIdentity.Column Is Nothing) Then
Dim name As String = e.TableCellIdentity.Column.Name
If Me.filterValues.ContainsKey(name) Then
e.Style.Text = Me.filterValues(name).ToString
End If
End If

End Sub

#End Region

Administrator [Syncfusion]
Replied On September 8, 2006 11:32 AM UTC


You can remove the RecordFilters in GridTableDescriptor, when you delete all the text from the cell. Here is a code snippet.

''Please change TableControlCurrentCellChanged event Else Part-> If ......
If cc.Renderer.ControlText = Nothing Or cc.Renderer.ControlText = String.Empty Then
End If

Let me know if this helps,

Best Regards,

Administrator [Syncfusion]
Replied On September 9, 2006 09:24 AM UTC

It is OK.
Best Regards


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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