SIGN UP MEMBER LOGIN:    
ARTICLE

Editable ListBox in C#

Posted by Gautam Shrestha Articles | Windows Controls C# June 09, 2005
The attached sample code demonstrates how you can create an editable ListBox control, which will let you edit ListBox items at runtime.
Reader Level:
Download Files:
 

Suppose you need to edit an item in a list box (it is read-only list of item) at a runtime. This sample code demonstrate a simple approach to create an editable listbox.

ListBox.gif

To edit an item in a list box, all you need is one hidden text box. Keep textbox hidden of set property visible as false and show it whenever you required.

share this article :
post comment
 

Very good concept used What caught ma attention was your logic applied in these lines : Rectangle r=this.listBox1.GetItemRectangle(itemSelected); this.textBox1.Location=new System.Drawing.Point(r.X+5,r.Y+5); this.textBox1.Size=new System.Drawing.Size(r.Width+4 , r.Height-10); this.textBox1.Visible=true; this.textBox1.Text=itemText; this.textBox1.Focus(); this.textBox1.SelectAll(); Very nice Mr. Gautam. Thank You for teaching me this beautiful concept.

Posted by Manoj Singh Panwar Dec 03, 2011

Dear Gautam it's really helpful to us but you should write some description about your article it may become more effective thanks.

Posted by Amit Maheshwari Dec 03, 2011

Very Good Code

Posted by Sanjay Tripathi Jun 19, 2009

Well you're assigning rather than comapring

Posted by Lasse Jaervensivu Jul 17, 2007

Hello gautam shrestha'

Plese tell me quick!

In c#(ASP.net) The concept is items are added to a list box from a TextBox. if the item is already appear inside the list box it shows Already exist otherwise it can be added. I had written the following query for that.

if(ListBox1.Items.Contains(TextBox1.Text)=True))

{

Response.Write("Already Exists");

}

else

{

ListBox1.Items.Add(TextBox1.Text)

}

But the above query doesn't worked. What is the reason Pls tell me quick otherwise I will became a mad!!!!!!!

Posted by santhanam krishnan Oct 28, 2006
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Nevron Gauge for SharePoint
Become a Sponsor