Hello,
I am adding a formula field to ugReport grid. It seem by default the Formula Builder loads all availble columns Infragistic controls (grids, dropdowns, so on...) . Is there a way to specify which control should be availble in for the user to create formula? Ideally, I want the user only to have access to all the columns of ugReport grid.
Also to hide the other grids you will need to hide them by name, the code is simple for that.
If e.OperandName = "gridname"
e.cancel = true
Oh that was easy, I sorted my problem and the problem of the original poster by changing the code in event on formulaBuilder_OperandInitializing event to the following:
Private Sub formulaBuilder_OperandInitializing(ByVal sender As Object, ByVal e As OperandInitializingEventArgs)
If Not (TypeOf e.OperandContext Is UltraGridColumn Or _
TypeOf e.OperandContext Is Infragistics.Win.UltraWinGrid.UltraGrid Or _
TypeOf e.OperandContext Is Infragistics.Win.UltraWinGrid.UltraGridBand Or _
TypeOf e.OperandContext Is String) Then
e.Cancel =True
End If
End Sub
I miss understood what the other function was doing I thought it was hiding the text fields when infact it was hiding the text functions which was working. I am not too bothered about hidng the text columns now I have functions that work with them (As I removed that event). Still wish I could rename the blooming columns :(
Alex
Hi, is there a code example for this? I am getting the same thing, I only want it to show me one particular grid but it shows me all the grids and drop downs on the form, I too am using the code in the sample, though slightly altered ShowFormulaBuilderDialog to return true/false for my purposes shown below.
Note it also does not seem to exclude the text fields either:
Dim mvarSummarySettings As SummarySettings
' See if the FormulaProvider is a SummarySettings
If (TypeOf e.FormulaProvider Is SummarySettings) Then
mvarSummarySettings = DirectCast(e.FormulaProvider, SummarySettings)
' Get the source column for the Summary
Dim summaryColumn As UltraGridColumn = mvarSummarySettings.SummaryPositionColumn
' It doesn't make sense for the Summary formula to use values from any
' other grid columns except the source column, so filter those out.
If (TypeOf e.OperandContext Is UltraGridColumn _
AndAlso Not e.OperandContext Is summaryColumn) Then
e.Cancel = True
' This event fires for each function added to the list
' of functions in the FormulaBuilder and provides the
' opportunity to cancel them.
Private Sub formulaBuilder_FunctionInitializing(ByVal sender As Object, ByVal e As FunctionInitializingEventArgs)
' Some of the available functions do not make sense for Integer
' data. So filter out functions.
Select Case (e.Function.Category)
Case "Information", "Logical", "TextAndData"
End Select
Public Function ShowFormulaBuilderDialog(ByVal formulaProvider As IFormulaProvider) As Boolean
' Declare a new FormulaBuilderDialog
Dim mvarFormulaBuilderDialog As FormulaBuilderDialog = New FormulaBuilderDialog(formulaProvider)
AddHandler mvarFormulaBuilderDialog.OperandInitializing, AddressOf formulaBuilder_OperandInitializing
AddHandler mvarFormulaBuilderDialog.FunctionInitializing, AddressOf formulaBuilder_FunctionInitializing
Try
' Show the dialog
Dim dResult As DialogResult = mvarFormulaBuilderDialog.ShowDialog(Me)
' If the user cancelled, do nothing
If (dResult = DialogResult.Cancel) Then Return False
' Apply the formula
formulaProvider.Formula = mvarFormulaBuilderDialog.Formula
Return True
Finally
' Whatever happens, make sure we disconnect from
' the events
RemoveHandler mvarFormulaBuilderDialog.OperandInitializing, AddressOf formulaBuilder_OperandInitializing
RemoveHandler mvarFormulaBuilderDialog.FunctionInitializing, AddressOf formulaBuilder_FunctionInitializing
End Try
Hi,
I took a look at the FormulaBuilder Runtime sample and it's doing exactly what you describe by hooking into the OperandInitializing event of the FormulaBuilderDialog and setting e.Cancel to true for the item that should not be shown.