Dynamics NAV Addin Example Large Button
Here is another example on how to create custom buttons in NAV and control events when they are pressed. In this example I’m actually using the WinForm Button controls and displaying them on a panel. When the button are pressed Nav code is triggered and you can add your own custom logic in it.
Here is a screenshot below. As you can see, there are two button with different sizes and colors and when you press then a nav message is displayed that you pressed it.
The code for CreateControl is as follows
protected override Control CreateControl()
{
Button button1 = new Button();
button1.Location = new System.Drawing.Point(39, 25);
button1.Name = "button1";
button1.Size = new System.Drawing.Size(75, 23);
button1.TabIndex = 0;
button1.Text = "button1";
button1.UseVisualStyleBackColor = true;
button1.Click += new System.EventHandler(button1_Click);
Button button2 = new Button();
button2.Location = new System.Drawing.Point(59, 55);
button2.Name = "Largebutton2";
button2.Size = new System.Drawing.Size(175, 123);
button2.TabIndex = 0;
button2.Text = "Largebutton2";
button2.BackColor = System.Drawing.Color.Tomato;
button2.UseVisualStyleBackColor = true;
button2.Click += new System.EventHandler(button2_Click);
Panel buttonpanel = new Panel();
buttonpanel.Controls.Add(button1);
buttonpanel.Controls.Add(button2);
buttonpanel.Location = new System.Drawing.Point(12, 12);
buttonpanel.Name = "outlookGroupBox1";
buttonpanel.Padding = new System.Windows.Forms.Padding(4, 22, 4, 4);
buttonpanel.Size = new System.Drawing.Size(376, 219);
buttonpanel.TabIndex = 0;
buttonpanel.Text = "Many Buttons";
return buttonpanel;
}
Here is the Visual Studio Project Source
*This post is locked for comments