Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 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 November 23rd, 2008, 10:19 AM
vik vik is offline
Registered User
 
Join Date: Nov 2008
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default WinForms ListBox with user control items

Hi,

I need some help in the following:
is it possible to populate a ListBox with Items that are UserControl elements? I need to code the following: I have a List of elements which all have some text (which needs to be editable by users), some links (editable), some priority (also needs to be changable). Therefore I thought the best way is to have a ListBox which's elements are User Controls with a TextBox (for the text), a NumericUpDown (to select the priority), and a ComboBox (to be able to edit the links).
Could somebody tell me how to do this? I could just find that it is possible to customly draw the items but to draw these controls from scratch is quite a big deal...
Thanks for your help!
Viktor

 
Old November 24th, 2008, 01:19 PM
Friend of Wrox
 
Join Date: Sep 2008
Posts: 234
Thanks: 0
Thanked 32 Times in 30 Posts
Default

When the user clicks on the listbox, what do you expect to show them? You might consider constructing a class with the items you want to save, but define them as pointers to the various control objects. Yes, C# supports pointers, but you have to define them as "unsafe" because they are not part of the supported MSIL component. You could then show a string element stored as part of the class in the listbox and, after they make their selection, use the pointers held in the class in whatever way you deem necessary. I don't really like this approach since it is not portable, nor do I like using controls (IU elements) as data objects (i.e., buffers). Still, it might suit your purposes.

Dr. Purdum


Jack Purdum, Ph.D.
Author: Beginning C# 3.0: Introduction to Object Oriented Programming (and 14 other programming texts)
 
Old November 26th, 2008, 02:19 PM
vik vik is offline
Registered User
 
Join Date: Nov 2008
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thank You very much for Your reply I think this will be suitable for me, could You please tell me some link/book where I could read some more about this topic?
Thanks a lot!
Viktor

 
Old November 27th, 2008, 10:44 AM
Friend of Wrox
 
Join Date: Sep 2008
Posts: 234
Thanks: 0
Thanked 32 Times in 30 Posts
Default

You might try googling "C# pointers", which is what I did and I found the following that discusses more-or-less what I said earlier:

http://www.c-sharpcorner.com/UploadF...sInCSharp.aspx

I like the c-sharpcorner.com site as it often has some clever code examples to read. Even though I'm two years younger than dirt, I'm never too old to learn something new!

Good luck!

Dr. Purdum


Jack Purdum, Ph.D.
Author: Beginning C# 3.0: Introduction to Object Oriented Programming (and 14 other programming texts)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting all listbox items Lucy_H85 C# 2005 2 December 1st, 2009 05:36 AM
Unhighlight Listbox Items selevanm Access VBA 1 March 7th, 2007 01:39 PM
listbox control items count shows 0. vikram_bendre ASP.NET 2.0 Basics 5 August 24th, 2006 08:37 AM
Showing Hyperlink in Winforms Datagrid control livehed C# 0 January 20th, 2006 01:56 PM
Max of listbox control items Snowingnow Beginning VB 6 1 November 22nd, 2004 02:05 PM





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