473,320 Members | 2,080 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

WinForms ComboBox vs WebForms DropDownList

Hi,

Just looking for some v2 guidance here...

In WebForms, the DropDownList control has an Items collection which contains
ListItem objects which, in turn, very conveniently contain a text property
and a value property.

In WinForms, the ComboBox control also has an Items collection which can
contain (as I understand it) pretty much any object which can display
something. However, virtually all of the examples I've seen on the Internet
(and certainly all of those in MSDN) demonstrate how to add string values to
a ComboBox. That's fine, of course, but what if you want to display a string
but hold an internal reference to, e.g., a numerical ID? Bog-standard
database stuff.

I've found a whole slew of examples showing how to do this by writing
wrapper classes and God knows what, but I'm thinking thus:

since the ComboBox Items collection can be a collection of any displayable
..NET objects, is there anything wrong with doing this?

MyComboBox.Items.Add(new System.Web.UI.Controls.ListItem("One", "1"));
MyComboBox.Items.Add(new System.Web.UI.Controls.ListItem("Two", "2"));
MyComboBox.Items.Add(new System.Web.UI.Controls.ListItem("Three", "3"));

Just because it's a WinForms app, is there anything intrinsically wrong with
using one of the Web namespaces? It's just another part of the Framework,
right? Just as I could use the VisualBasic namespace in C# if I really
wanted to (e.g. to use IsNumeric, or whatever)...

Any assistance gratefully received.

Mark
Feb 24 '06 #1
2 10275
Mark,
Obviously you already understand the difference between the web version and
the Winforms versions.

So, I think the real question is "Does it work?". If it works, and this
makes you feel, better, then "knock yerself out", IMHO.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Mark Rae" wrote:
Hi,

Just looking for some v2 guidance here...

In WebForms, the DropDownList control has an Items collection which contains
ListItem objects which, in turn, very conveniently contain a text property
and a value property.

In WinForms, the ComboBox control also has an Items collection which can
contain (as I understand it) pretty much any object which can display
something. However, virtually all of the examples I've seen on the Internet
(and certainly all of those in MSDN) demonstrate how to add string values to
a ComboBox. That's fine, of course, but what if you want to display a string
but hold an internal reference to, e.g., a numerical ID? Bog-standard
database stuff.

I've found a whole slew of examples showing how to do this by writing
wrapper classes and God knows what, but I'm thinking thus:

since the ComboBox Items collection can be a collection of any displayable
..NET objects, is there anything wrong with doing this?

MyComboBox.Items.Add(new System.Web.UI.Controls.ListItem("One", "1"));
MyComboBox.Items.Add(new System.Web.UI.Controls.ListItem("Two", "2"));
MyComboBox.Items.Add(new System.Web.UI.Controls.ListItem("Three", "3"));

Just because it's a WinForms app, is there anything intrinsically wrong with
using one of the Web namespaces? It's just another part of the Framework,
right? Just as I could use the VisualBasic namespace in C# if I really
wanted to (e.g. to use IsNumeric, or whatever)...

Any assistance gratefully received.

Mark

Feb 24 '06 #2
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:A8**********************************@microsof t.com...
Obviously you already understand the difference between the web version
and
the Winforms versions.
I believe so...
So, I think the real question is "Does it work?".


Works perfectly.
Feb 24 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: BillyTheKid | last post by:
Are there any rules of thumb for when it is more appropriate to use WinForms over WebForms. It strikes me that WinForms is best suited for many/most "Intranet" and some "Extranet" scenarios but...
10
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ...
20
by: Martin Rosén-Lidholm | last post by:
Although an impossible question to answer, I fell urged to raise it anyhow. Given a fairly complex ERP application scenario, what's your estimation for the X-ratio dev. time for...
19
by: Bernie Yaeger | last post by:
Everyone misses the point on this - what we need is a combobox autocomplete that is a dropdownlist only. When in dropdown mode, you can enter text - making that autocomplete is trivial. But when...
2
by: Mahesh Kumar.R | last post by:
I'm into designing an application in winforms but in near future my client may request the same thing in webforms. so (1) what are all the design guidelines and ways are there to migrate easily in...
4
by: 3Cooks | last post by:
I have a windows application written in Visual Basic 6.0 that is going to be redeveloped in dotNET. We are trying to decide if we should deploy using Webforms or Winforms and I need advice from...
5
by: dwight | last post by:
Hi all First - I apologise if anyone recognises this from a previous post but I never worded what I wanted to know properly and getting quick advice is imperative to me now. In future I will...
5
by: brian.wilson4 | last post by:
Our group is currently comparing winforms vs webforms.....app is Corp LAN based - we have control of desktops.....Below is pros and cons list we have come up with - if anything strikes you as...
5
by: Bit byte | last post by:
Can I use C# (Winforms) to design a website?. I am from C/C++ background but know nothing about Internet programming. My understanding of WebForms are that they are similar to WinForms in that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.