A reusable control add-in button

Capone
Member Posts: 125
Hi!
I'm trying to create a resuable ControlAddIn button on pages. A button which I can reuse and set name and size dynamicaly
I managed to create it and with proper methods to do this. However, the problem I'm struggling with is to set the properties of the add-in at the startup of the page.
According to this http://msdn.microsoft.com/en-us/library/hh168173(v=nav.70).aspx I can't set this properties in the trigger OnInit, OnOpenPage and OnNewRecord because the control is not instantiated which is was of my points with this reusable add-in.
I have also tried the trigger OnAfterGetRecord but the same result.
One thought was to create static properties and methods that could set these values before instansiation but that failed since static members can't be shown in the symbol menu(?).
A workaround is to hide the Controls on the page and then show the with an action that changes the properties at the same time.
Does anyone have a better suggestion of a workaround or solution?
I'm trying to create a resuable ControlAddIn button on pages. A button which I can reuse and set name and size dynamicaly
I managed to create it and with proper methods to do this. However, the problem I'm struggling with is to set the properties of the add-in at the startup of the page.
According to this http://msdn.microsoft.com/en-us/library/hh168173(v=nav.70).aspx I can't set this properties in the trigger OnInit, OnOpenPage and OnNewRecord because the control is not instantiated which is was of my points with this reusable add-in.
I have also tried the trigger OnAfterGetRecord but the same result.
One thought was to create static properties and methods that could set these values before instansiation but that failed since static members can't be shown in the symbol menu(?).
A workaround is to hide the Controls on the page and then show the with an action that changes the properties at the same time.
Does anyone have a better suggestion of a workaround or solution?
Hello IT, have you tried to turn it off and on?
Have you checked the cables?
Have you released the filters?
http://www.navfreak.com
Have you checked the cables?
Have you released the filters?
http://www.navfreak.com
0
Answers
-
Solved it! \:D/
I realised that I could do a callback to NAV from the CreateControl method and in NAV set the properties.
Visual Studio Codeusing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Dynamics.Framework.UI.Extensibility; using Microsoft.Dynamics.Framework.UI.Extensibility.WinForms; using System.Windows.Forms; using System.Drawing; namespace DynamicButton { [ControlAddInExport("DynamicButtonAddin")] public class DynamicButton : WinFormsControlAddInBase, IEventControlAddInDefinition { Int32 Width, Height, LocationX, LocationY; String ButtonText; Button button1; protected override Control CreateControl() { ButtonText = "Button"; Width = 75; Height = 23; button1 = new Button(); button1.Location = new System.Drawing.Point(LocationX, LocationY); button1.Name = "Button01"; button1.Size = new System.Drawing.Size(Width, Height); button1.TabIndex = 0; button1.Text = ButtonText; button1.UseVisualStyleBackColor = true; button1.Click += new System.EventHandler(button1_Click); ControlAddIn(0, ""); return button1; } void button1_Click(object sender, System.EventArgs e) { ControlAddIn(1, ""); } public event ControlAddInEventHandler ControlAddIn; [ApplicationVisible] public void SetButtonText(String Text) { ButtonText = Text; button1.Text = ButtonText; } [ApplicationVisible] public void SetButtonSize(Int32 w, Int32 h) { this.ApplySize(new DisplaySize(w,w,w),new DisplaySize(h,h,h)); } } }
Code in Control trigger in NAV:TestCTRL - OnControlAddIn(Index : Integer;Data : Text) IF Index = 0 THEN BEGIN CurrPage.TestCTRL.SetButtonSize(100,100); CurrPage.TestCTRL.SetButtonText('Dynamic Text'); END; IF Index = 1 THEN ;//Do Something
Hello IT, have you tried to turn it off and on?
Have you checked the cables?
Have you released the filters?
http://www.navfreak.com0 -
nice, and thx, not sure how you would use this0
-
How about touchscreen friendly interface?
Think of it as a button control you can place on a page.
Also, instead of creating a button addin to every button you need I wanted to create a general one which you can reuse.Hello IT, have you tried to turn it off and on?
Have you checked the cables?
Have you released the filters?
http://www.navfreak.com0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions