Posts

Showing posts from November, 2013

Featured Post

Smart Product designer

Image
download and purchase link: https://alkanyx.com/item/49/Smart+Product+designer

Live preview : http://smartproductdesigner.000webhostapp.com/

Smart Product Designer is a  tool to create your own product and get directly from your website. It is well documented, very easy to customize and use. It is build using most advance technologies including javascript, jQuery and html5.
Features Choose different product from collectionAdd custom texts to product.Change text colorChange the size and font of the TextLet the user drag, move or remove elementsAdd images to product selected from art gallery or browse it from systemDesign both frontside and back-sideShows preview while designingDownload designVery easy to customize and useHere is the purchase link : https://alkanyx.com/item/49/Smart+Product+designer

How to add ActiveX control at run time using C#.NET

Hi, recently I worked on a project where the requirement was to add an ActiveX control dynamically to a UserControl type project. Here I was trying to add that activeX control to multiple tab pages of a tab control.

Here is the code that I used -

for(int i = 0; i < 4; i++)
{
      this.LineTabs.TabPages.Add(i);
      AxTree treeadd = treeload(this.LineTabs.TabPages[i]);
}

In the above code I am creating four tab pages at runtime and adding ActiveX control "AxTree" to these pages dynamically using function "treeload".

Here is the code for "treeload" function -

private AxTree treeload(TabPage tab)
    {
        AxTree treeobject = new AxTree();
        ((System.ComponentModel.ISupportInitialize)(treeobject)).BeginInit();
        SuspendLayout();
        tab.Controls.Add(treeobject);
        treeobject.Dock = DockStyle.Fill;
        ResumeLayout();
        ((System.ComponentModel.ISupportInitialize)(treeobject)).EndInit();

        return treeobject;
    }

Dynamically adding controls to web form and their event handling in ASP.NET using C#

Add control dynamically using code on web form Sometimes in web form we need to add controls using code. Following C# code can be used to add button control dynamically to web form.

    Button btn1 = new Button();
    btn1.Text = "New Button";
    this.Controls.Add(btn1);

To add the dynamically created button control to a Panel control use following code -

Panel1.Controls.Add(btn1);
Event Handler for dynamically added control We can use following code to declare click event for dynamically added button code-   btn1.Click += new EventHandler(btnClick);
After declaring the click event, define the event handler using C# - private void btnClick(object sender, EventArgs e)
{
      Button btn = (Button)sender;  //get the button which is                                       clicked
      // write your code
}

So, the complete code becomes -

 {
    Button btn1 = new Button();
    btn1.Text = "New Button";
    this.Controls.Add(btn1);
    btn1.Click += new EventHandler(btnClick);
 }