add custom controls to sales order form  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

add custom controls to sales order form

Postby perry » Wed Sep 03, 2014 2:22 pm

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)
Perry Ma
S. Programmer
Lonicera Pty Ltd
http://www.lonicera.com.au
perry
Frequent Contributor
Frequent Contributor
 
Posts: 173
Joined: Mon Oct 27, 2008 2:26 pm
Topics Solved: 15

Re: add custom controls to sales order form

Postby Mike.Sheen » Thu Sep 04, 2014 12:05 pm

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
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: add custom controls to sales order form

Postby perry » Thu Sep 04, 2014 12:18 pm

thanks!
Perry Ma
S. Programmer
Lonicera Pty Ltd
http://www.lonicera.com.au
perry
Frequent Contributor
Frequent Contributor
 
Posts: 173
Joined: Mon Oct 27, 2008 2:26 pm
Topics Solved: 15

Re: add custom controls to sales order form

Postby perry » Thu Sep 04, 2014 3:30 pm

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)
Perry Ma
S. Programmer
Lonicera Pty Ltd
http://www.lonicera.com.au
perry
Frequent Contributor
Frequent Contributor
 
Posts: 173
Joined: Mon Oct 27, 2008 2:26 pm
Topics Solved: 15

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

Postby Mike.Sheen » Thu Sep 04, 2014 7:13 pm

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
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests