Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 19th, 2005, 01:13 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Default adding SelectedIndexChanged event to listbox

Hi

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.

thanks

 
Old July 19th, 2005, 02:47 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

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.

J





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





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