Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have managed to show a <code>MonthCalendar</code> when you press the icon to filter a DateTime column in an UltraWinGrid.<br> When the <code>MonthCalendar</code> is dispayed you could select a specific date using the familiar interface provided by this standard WinForm control. After selecting the date you could use the value to apply programmatically a filter condition to the UltraWinGrid column. </p> <p>To reach this result you first need to add a reference to the <strong>Infragistics4.Win.SupportsDialog.v11.2</strong> assembly where you can find the <strong>UltraGridFilterUIProvider</strong> class </p> <p>Now, in your form where you need the filtering to appear, add this code: (it is just an example because I haven't your datasource and thus I have a prebuilt one with just one datetime column)</p> <pre><code>Imports Infragistics.Win.UltraWinGrid Imports Infragistics.Win.SupportDialogs.FilterUIProvider Public Class Form1 ' This is the key object that let us customize ' ' the Filter for the UltraWinGrid' Dim _filterUIProvider as UltraGridFilterUIProvider ' In the InitializeLayout event we substitute the normal ' filter handler with the custom filter' Private Sub UltraGrid1_InitializeLayout(sender As Object, e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles UltraGrid1.InitializeLayout e.Layout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.True _filterUIProvider = New UltraGridFilterUIProvider() ' Comment out the following line to test the default ' **Excel Filter Style Interface** ' AddHandler _filterUIProvider.BeforeMenuPopulate, AddressOf _filterUIProvider_BeforeMenuPopulate e.Layout.Override.FilterUIProvider = _filterUIProvider End Sub ' Before the UltraGridFilterUIProvider shows its standard form interface ' we start a custom form used to apply our filtering logic ' ' and block the display of the UltraGridFilterUIProvider interface ' Private Sub _filterUIProvider_BeforeMenuPopulate(sender As Object, e As Infragistics.Win.SupportDialogs.FilterUIProvider.BeforeMenuPopulateEventArgs) ' A custom form with the MonthCalendar and 3 buttons ' ' to handle the filter logic ' Using fDate = new FormDate() ' Open our custom form with the monthcalendar if (DialogResult.OK = fDate.ShowDialog()) ' We need a nullable date to allow the removing of the filter' Dim dtFilter As DateTime? = fDate.SelectedDate if (dtFilter.HasValue) ' Apply programmatically a filtercondition to the column ' In this case I have only one column. so I use the index 0 ' in your case this should change to reflect your column index Dim fc = new FilterCondition(FilterComparisionOperator.Equals, dtFilter.Value) ultraGrid1.DisplayLayout.Bands(0).ColumnFilters(0).FilterConditions.Add(fc) Else ultraGrid1.DisplayLayout.Bands(0).ColumnFilters.ClearAllFilters() End If End If End Using e.Handled = true ' Stop the standard interface' End Sub End Class </code></pre> <p>Now we need only a simple form called <strong>FormDate</strong> that contains a MonthCalendar and three buttons (Set, Clear, Cancel) that return (Set) a Date to set the filter, (Clear) a null value to remove previous filter and a cancel button to abort the processing</p> <p>Here the code for the form, the design is trivial</p> <pre><code>Public Class FormDate Public Property SelectedDate As DateTime? Private Sub FormDate_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.SelectedDate = Nothing End Sub Private Sub cmdSet_Click(sender As Object, e As EventArgs) Handles cmdSet.Click 'This button has DialogResult=OK' Me.SelectedDate = monthCalendar1.SelectionStart End Sub Private Sub cmdClear_Click(sender As Object, e As EventArgs) Handles cmdClear.Click 'This button has DialogResult=OK' Me.SelectedDate = Nothing End Sub End Class </code></pre> <p>This could resolve your problem, however, I have discoverd what seems to be a bug in UltraGridFilterUIProvider. When I call the <strong>e.Handled=True</strong> my expected result is the filter to not show anything but, instead a small window still appears and I have to press Escape to hide it. I have not found any way to automatically hide it.<br> It seems to be a problem to signal to the Infragistics team.</p> <p>I suggest you also to test the <strong>Excel Style Filter Interface</strong> provided automatically by the UltraGridFilterUIProvider. This interface has a lot of options and is much more preferable to the standard UI filter. To test this interface you should only comment out the AddHandler line above</p> <p><strong>EDIT</strong> Following the comment from @Alhalama I have tried to use the BeforeRowFilterDropDown event and the result are better (well it is perfect now). So I have commented out the line with the AddHandler, removed the code for the BeforeMenuPopulate and added the code for the BeforeRowFilterDropDown</p> <pre><code>Private Sub UltraGrid1_BeforeRowFilterDropDown(sender As Object, e As BeforeRowFilterDropDownEventArgs) Handles UltraGrid1.BeforeRowFilterDropDown If e.Column.Key = "DateRequest" Then Using fDate = New FormDate() If DialogResult.OK = fDate.ShowDialog() Then Dim dtFilter As DateTime? = fDate.SelectedDate If (dtFilter.HasValue) Then Dim fc As FilterCondition = New FilterCondition(FilterComparisionOperator.Equals, dtFilter.Value) UltraGrid1.DisplayLayout.Bands(0).ColumnFilters(0).FilterConditions.Add(fc) Else UltraGrid1.DisplayLayout.Bands(0).ColumnFilters.ClearAllFilters() End If End If End Using e.Cancel = True End If End Sub </code></pre> <p>Now, when I try to open the filter for the column named <strong>DateRequest</strong> I open immediately the FormDate and at the end I set the Cancel property of the BeforeRowFilterDropDownEventArgs to true to avoid further processing of the filter dialog. This seems to be perfect...... Great credit for this to Mr. Alhalama. If you wish I think you should post your own answer because your suggestion really makes the difference.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload