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.
Syncfusion Feedback

GGC filterbar using textboxes

Thread ID:

Created:

Updated:

Platform:

Replies:

48988 Sep 7,2006 01:30 PM Sep 9,2006 05:24 AM Windows Forms 2
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On September 7, 2006 01:30 PM

Hi
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?

Thanks!

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.TableControl.Table.CurrentRecordManager.LeaveRecord(False)
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
cc.Lock()
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)
Else
style.TableCellIdentity.Table.TableDescriptor.RecordFilters(colName).Expression = expression
filterValues(colName) = cc.Renderer.ControlText
If cc.Renderer.ControlText = Nothing Then
filterValues.Remove(colName)
GridGroupingControl1.Refresh()
End If
End If
CType(sender, GridGroupingControl).Update()
cc.Unlock()
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 07:32 AM

Hi,

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
style.TableCellIdentity.Table.TableDescriptor.RecordFilters.Remove(colName)
filterValues.Remove(colName)
End If

Let me know if this helps,

Best Regards,
Haneef

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

Thanks!
It is OK.
Best Regards

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

;