Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Custom Controls And Events

Custom Controls And Events

Scheduled Pinned Locked Moved C#
graphicsdockerhelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rich_wenger
    wrote on last edited by
    #1

    I've go a Custom Control that inherits from the TextBox class and I've added a ListBox; I needed to create a custom event exposed to the parent form that would fire when the ListBox changed visiblity. The code below works but I know it's now quite right. Any help appreciated. Control Code Snippet============================================== using System; using System.Collections; using System.ComponentModel; using System.Drawing; using System.Data; using System.Windows.Forms; public delegate void ListBoxEvent(); namespace TextBoxLookupLib { /// /// Custom Textbox Control /// public class TextBoxLookup : System.Windows.Forms.TextBox { private System.Windows.Forms.ListBox listBox1; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public event ListBoxEvent ListBoxVisibleChanged; public TextBoxLookup() { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); // TODO: Add any initialization after the InitComponent call this.listBox1.Visible = false; this.listBox1.Width = this.Width; this.listBox1.TabStop = false; this.DoubleClick +=new EventHandler(TextBoxLookup_DoubleClick); this.listBox1.DoubleClick +=new EventHandler(listBox1_DoubleClick); this.listBox1.VisibleChanged +=new EventHandler(listBox1_VisibleChanged); ListBoxVisibleChanged += new ListBoxEvent(OnListBoxVisibleChanged); } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if( components != null ) components.Dispose(); } base.Dispose( disposing ); } #region Component Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.listBox1 = new System.Windows.Forms.ListBox(); // // listBox1 // this.listBox1.Location = new System.Drawing.Point(17, 17); this.listBox1.Name = "listBox1"; this.listBox1.TabIndex = 0; } #endregion private void OpenListBox() { Control ctlParent = this.Parent; ctlParent.Controls.Add(this.listBox1); this.listBox1.Width = this.Width; this.listBox1.BringToFront(); this.listBox1.Visible = true; } private void CloseListBox() { this.Focu

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups