Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 19th, 2005, 01:13 PM
Friend of Wrox
Join Date: Sep 2003
Location: , , .
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Default adding SelectedIndexChanged event to listbox


I am creating Listbox dyamically like below.I want to add SelectedIndexChanged event to my listbox dynamically.

    System.Web.UI.WebControls.ListBox lst = new System.Web.UI.WebControls.ListBox();
    lst.Style["TOP"] = t.Style["TOP"];
    lst.Style["LEFT"] = t.Style["LEFT"];
    lst.Style["POSITION"] = t.Style["POSITION"];
    lst.Style["HEIGHT"] = t.Style["HEIGHT"];
    lst.Style["WIDTH"] = t.Style["WIDTH"];
    lst.TabIndex = t.TabIndex ;
    lst.Enabled = t.Enabled;
    lst.Height = t.Height;
    lst.Width = t.Width;
    lst.BackColor = t.BackColor;
    lst.SelectionMode=ListSelectionMode.Multiple ;
    lst.AutoPostBack =true;

Pl advice me how to add SelectedIndexChanged event.


Reply With Quote
  #2 (permalink)  
Old July 19th, 2005, 02:47 PM
Friend of Wrox
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts

Use the WithEvents keyword when you declare your listbox.
Dim WithEvents As lst System.Web.UI.WebControls.Listbox
This will allow you to access its events in your code.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
selectedindexchanged event not firing kaliaparijat ASP.NET 2.0 Professional 1 June 5th, 2008 08:58 AM
GridView SelectedIndexChanged event bnorg ASP.NET 2.0 Professional 1 July 7th, 2007 01:14 AM
ListBox.SelectedIndexChanged not fired (composite) studen77 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 March 27th, 2007 08:40 PM
Listbox selectedindexchanged event venterjo General .NET 6 December 9th, 2004 08:46 AM
listbox event SelectedIndexChanged alyeng2000 ASP.NET 1.0 and 1.1 Basics 2 December 22nd, 2003 10:50 PM

All times are GMT -4. The time now is 01:48 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.