ButtonCollection.cs :  » Database » SQL-Power-Injector » SQLPowerInjector » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Database » SQL Power Injector 
SQL Power Injector » SQLPowerInjector » ButtonCollection.cs
//************************************************************************
//                                      //
//  SQL Power Injector 1.2 Copyright (c) 2006-2007 Francois Larouche //
//                                      //
//  Authors  : Francois Larouche                                         //
//            Inspired on source code from MSDN website by Matthew A.   // 
//            Stoecker, Microsoft Corporation                         //
//  Web Site: http://msdn.microsoft.com/library/default.asp?url=/       //
//            library/en-us/dv_vstechart/html/                          //
//            vbtchCreatingControlArraysInVisualBasicNETVisualCNET.asp  //
//                                      //
//**********************************************************************//
using System;
using System.Windows.Forms;
using System.Drawing;

namespace SQLPowerInjector{
  public delegate void ClickEventHandler(object sender, EventArgs e);

  /// <summary>
  /// Summary description for ButtonCollection.
  /// </summary>
  public class ButtonCollection : System.Collections.CollectionBase
  {
    #region Members
    #region Private
    private readonly Form _hostForm;
    #endregion
    #endregion

    #region Constructor
    public ButtonCollection(Form host)
    {
      _hostForm = host;
    }
    #endregion

    #region Public Attributes
    public Button this[int Index]
    {
      get
      {
        return (Button)this.List[Index];
      }
    }
    #endregion

    public event ClickEventHandler Clicked;

    public Button AddNewButton(int topPos, int leftPos, int sizeWidth, int sizeHeight, string buttonText)
    {
      Button curButton = new Button();
      // Add the button to the collection's internal list.
      this.List.Add(curButton);
      // Add the button to the controls collection of the form 
      // referenced by the _hostForm field.
      _hostForm.Controls.Add(curButton);

      curButton.Top = topPos;
      curButton.Left = leftPos;
      curButton.Size = new System.Drawing.Size(sizeWidth, sizeHeight);
      curButton.Tag = this.Count - 1;
      curButton.Text = buttonText;

      curButton.Click += new System.EventHandler(ClickHandler);

      return curButton;
    }

    public void Remove(int buttonIndex)
    {
      // Check to be sure there is a button to remove.
      if (this.Count > 0 && buttonIndex <= this.Count)
      {
        _hostForm.Controls.Remove(this[buttonIndex]);
        this.List.RemoveAt(buttonIndex);
      }
    }

    public void ClickHandler(Object sender, System.EventArgs e)
    {
      if(Clicked != null)
        Clicked(sender, e);
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.