Page 1 of 1

add custom controls to sales order form

PostPosted: Wed Sep 03, 2014 2:22 pm
by perry
Hi,

Jiwa 7.0.78

Can you provide sample code to add some controls between grdCartage and grdTotals please?

I tried below but the label is not visible on the form.

Code: Select all
TestLabel = New Infragistics.Win.Misc.UltraLabel
With TestLabel
   .Location = New System.Drawing.Point(SOUI.grdCartage.Location.X + SOUI.grdCartage.Width + 20, SOUI.grdCartage.Location.Y)
   .Appearance = SOUI.lblReference.Appearance
   .Dock = System.Windows.Forms.DockStyle.None
   .Name = "TestLabel"
   .Size = SOUI.lblReference.Size
   .Text = "Test Label"

End With
'SOUI.MainTabControl.Tabs.Item("Main").TabPage.Controls.Add(SOTotalWeightLabel)
'SOUI.UltraPanel2.ClientArea.Controls.Add(SOTotalWeightLabel)
SOUI.grdCartage.Parent.Controls.Add(TestLabel)

Re: add custom controls to sales order form

PostPosted: Thu Sep 04, 2014 12:05 pm
by Mike.Sheen
perry wrote:I tried below but the label is not visible on the form.

Hi Perry,

If the code in your sample was run during the Setup or SetupBefore handlers, then the location of the controls may not be the location as when the form is shown, as it will be resized.

You're setting your labels location to be relative to the grdCartage control, but that control's location changes after your code is run. If you added a code to set grdLines.Visible = False, you'll see your control about half way down the form.

Because the grdCartage control has anchoring of bottom left, you need to set the anchor of your label to be also bottom left, as well as a location relative to the grdCartage control for it to always appear relative to the grdCartage control.

So - add this inside your With block:
Code: Select all
.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left


Mike

Re: add custom controls to sales order form

PostPosted: Thu Sep 04, 2014 12:18 pm
by perry
thanks!

Re: add custom controls to sales order form

PostPosted: Thu Sep 04, 2014 3:30 pm
by perry
Hi Mike,

Another problem on the same topic.

This time is inventory UI, adding Edit1 + Label1 + Edit2 and to the right of INVUI.FreeNumericEditor.

With codes below, Edit1 is in correct position but not label1 and edit2...they went after SOHFreeLabel...
Do I need to add more columns to the tablelayout? This positioning control thing from plugin is driving me crazy...

Code: Select all
INVUI = DirectCast(JiwaForm, JiwaInventoryUI.InventoryMaintenanceForm)
TestEdit1 = New JiwaApplication.Controls.NumericEditor
'TestEdit1
With TestEdit1
   .Location = New System.Drawing.Point(INVUI.FreeNumericEditor.Location.X + INVUI.FreeNumericEditor.Width + 20, INVUI.FreeNumericEditor.Location.Y)
   .DecimalPlaces = 2
   .MaskClipMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.Raw
   .MaskDisplayMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeLiterals
   .MaskInput = "-nnn,nnn,nnn,nnn,nnn.nn"
   .Name = "TestEdit1"
   .NumericType = Infragistics.Win.UltraWinEditors.NumericType.[Decimal]
   .PromptChar = Global.Microsoft.VisualBasic.ChrW(32)
   .Size = INVUI.FreeNumericEditor.Size
   .ThousandsSeparator = True
   .ThousandsSeparatorChar = Global.Microsoft.VisualBasic.ChrW(44)
   .Enabled = False
   .Anchor = Windows.Forms.AnchorStyles.Bottom Or Windows.Forms.AnchorStyles.Left
End With
INVUI.FreeNumericEditor.Parent.Controls.Add(TestEdit1)

'TestLabel1
TestLabel1 = New Infragistics.Win.Misc.UltraLabel
With TestLabel1
   .Location = New System.Drawing.Point(TestEdit1.Location.X + TestEdit1.Width + 20, INVUI.SOHFreeLabel.Location.Y)
   '.Appearance = INVUI.SOHFreeLabel.Appearance
   '.Dock = System.Windows.Forms.DockStyle.None
   .Name = "TestLabel1"
   .Size = INVUI.SOHFreeLabel.Size
   .Text = "TestLabel1"
   .Anchor = Windows.Forms.AnchorStyles.Bottom Or Windows.Forms.AnchorStyles.Left
End With
INVUI.FreeNumericEditor.Parent.Controls.Add(TestLabel1)

TestEdit2 = New JiwaApplication.Controls.NumericEditor
'TestEdit2
With TestEdit2
   .Location = New System.Drawing.Point(TestLabel1.Location.X + TestLabel1.Width + 20, TestEdit1.Location.Y)
   .DecimalPlaces = 2
   .MaskClipMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.Raw
   .MaskDisplayMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeLiterals
   .MaskInput = "-nnn,nnn,nnn,nnn,nnn.nn"
   .Name = "TestEdit2"
   .NumericType = Infragistics.Win.UltraWinEditors.NumericType.[Decimal]
   .PromptChar = Global.Microsoft.VisualBasic.ChrW(32)
   .Size = INVUI.FreeNumericEditor.Size
   .ThousandsSeparator = True
   .ThousandsSeparatorChar = Global.Microsoft.VisualBasic.ChrW(44)
   .Enabled = False
   .Anchor = Windows.Forms.AnchorStyles.Bottom Or Windows.Forms.AnchorStyles.Left
End With
INVUI.FreeNumericEditor.Parent.Controls.Add(TestEdit2)

Re: add custom controls to sales order form  Topic is solved

PostPosted: Thu Sep 04, 2014 7:13 pm
by Mike.Sheen
perry wrote:Do I need to add more columns to the tablelayout? This positioning control thing from plugin is driving me crazy...


Yep, in the plugin in you should be setting the controls Col and Row properties.

When I look at the Inventory Maintenance form, SOH - Transaction Detail in the Visual Studio designer - it looks like this:
InventoryMaintenanceDesigner.PNG

Note the control with the focus is the TableLayoutPanel5 control - that is the control the FreeNumericEditor control sits in. The positioning of the control is not done by setting the location and size - but by setting the Col and Row extender properties introduced when the control was placed. To give an idea, here's the designer code relating to the FreeNumericEditor:

Code: Select all
        Me.TableLayoutPanel5.Controls.Add(Me.FreeNumericEditor, 3, 0)       ' <--- Note the 3,0 is the Col,Row parameters.
        '
        'FreeNumericEditor
        '
        Me.FreeNumericEditor.DecimalPlaces = 2
        Me.FreeNumericEditor.Dock = System.Windows.Forms.DockStyle.Fill
        Me.FreeNumericEditor.Location = New System.Drawing.Point(303, 3)
        Me.FreeNumericEditor.MaskClipMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.Raw
        Me.FreeNumericEditor.MaskDisplayMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeLiterals
        Me.FreeNumericEditor.MaskInput = "-nnn,nnn,nnn,nnn,nnn.nn"
        Me.FreeNumericEditor.MaxValue = 9999999999999.99R
        Me.FreeNumericEditor.Name = "FreeNumericEditor"
        Me.FreeNumericEditor.Nullable = True
        Me.FreeNumericEditor.NumericType = Infragistics.Win.UltraWinEditors.NumericType.[Decimal]
        Me.FreeNumericEditor.PromptChar = Global.Microsoft.VisualBasic.ChrW(32)
        Me.FreeNumericEditor.Size = New System.Drawing.Size(94, 21)
        Me.FreeNumericEditor.TabIndex = 18
        Me.FreeNumericEditor.TabNavigation = Infragistics.Win.UltraWinMaskedEdit.MaskedEditTabNavigation.NextControl
        Me.FreeNumericEditor.ThousandsSeparator = True
        Me.FreeNumericEditor.ThousandsSeparatorChar = Global.Microsoft.VisualBasic.ChrW(44)


If you want to add more controls within that TableLayoutPanel control, you will need to add some columns to it first. I think the reason it worked with your first control is because there is one spare cell to the right of the cell the FreeNumericEditor resides in - i.e.: it set the Col and Row for you automatically to the first free spot. To assist you, here is the designer code for that layout panel:

Code: Select all
'
        'TableLayoutPanel5
        '
        Me.TableLayoutPanel5.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.TableLayoutPanel5.ColumnCount = 7
        Me.TableLayoutPanel5.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 130.0!))
        Me.TableLayoutPanel5.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 63.0!))
        Me.TableLayoutPanel5.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 107.0!))
        Me.TableLayoutPanel5.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100.0!))
        Me.TableLayoutPanel5.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100.0!))
        Me.TableLayoutPanel5.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 129.0!))
        Me.TableLayoutPanel5.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 281.0!))
        Me.TableLayoutPanel5.Controls.Add(Me.FreeNumericEditor, 3, 0)
        Me.TableLayoutPanel5.Controls.Add(Me.SOHNumericEditor, 2, 0)
        Me.TableLayoutPanel5.Controls.Add(Me.SOHFreeLabel, 1, 0)
        Me.TableLayoutPanel5.Controls.Add(Me.SOHShowZeroValuesCheckBox, 0, 0)
        Me.TableLayoutPanel5.Controls.Add(Me.SOHSpecificWarehouseCheckBox, 5, 0)
        Me.TableLayoutPanel5.Controls.Add(Me.SOHSpecificWarehouseLookup, 6, 0)
        Me.TableLayoutPanel5.Location = New System.Drawing.Point(3, 276)
        Me.TableLayoutPanel5.Name = "TableLayoutPanel5"
        Me.TableLayoutPanel5.RowCount = 1
        Me.TableLayoutPanel5.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26.0!))
        Me.TableLayoutPanel5.Size = New System.Drawing.Size(943, 24)
        Me.InboxControlStyler1.SetStyleSettings(Me.TableLayoutPanel5, New Infragistics.Win.AppStyling.Runtime.InboxControlStyleSettings(Infragistics.Win.DefaultableBoolean.[Default]))


Mike