hi
Currently I am working in C# windows application. I am trying to fill combo box with values
We have to always use datasource property for filling values in Combo box?
In VB, normally i have used Item data property and display data property
We can't use this similar method in C#?? please let me know.
thankjs
Kannan 3 19393
it's very easy - ex :
ComboBox cb = new ComboBox();
string s = "hi";
cb.Items.Add( s );
// or
cb.Items.AddRange( anObjectArray );
where anObjectArray is an array of System.Object based objects such as
strings etc.
;-)
"Kannan" <an*******@discussions.microsoft.com> wrote in message
news:C2**********************************@microsof t.com... hi, Currently I am working in C# windows application. I am trying to fill
combo box with values. We have to always use datasource property for filling values in Combo
box?? In VB, normally i have used Item data property and display data property. We can't use this similar method in C#?? please let me know.
thankjs, Kannan
I usually use a helper class that overrides the ToString() method. Any class
that overrides the ToString() method with a "useful" string will work.
public class ComboBoxItem
{
private string display;
private object data;
public ComboBoxItem(string display, object data)
{
this.display = display;
this.data = data;
}
public override string ToString()
{
return display;
}
}
You'd add it to your ComboBox like this:
comboBox.Items.Add(new ComboBoxItem("asdf", yourObjectHere));
"Kannan" <an*******@discussions.microsoft.com> wrote in message
news:7F**********************************@microsof t.com... hi, thanks for your quick response. But my question is related to design time. Is it possible can we do it in design time without using datasource
property. In VB, I have used Item data and value data property. similarly what is
available in C# combo box (without using datasource property)? please let me know.
thanks, Kannan
----- gary hitch wrote: -----
it's very easy - ex :
ComboBox cb = new ComboBox(); string s = "hi"; cb.Items.Add( s ); // or cb.Items.AddRange( anObjectArray );
where anObjectArray is an array of System.Object based objects such
as strings etc.
;-)
"Kannan" <an*******@discussions.microsoft.com> wrote in message news:C2**********************************@microsof t.com... > hi, > Currently I am working in C# windows application. I am trying to
fill combo box with values. > We have to always use datasource property for filling values in
Combo box?? > In VB, normally i have used Item data property and display data
property. > We can't use this similar method in C#?? please let me know. >> thankjs, > Kannan
you do this at design time through the Properties page in the Items property
click the property and a [...] button appears on the right of the field -
click it and you get a dialog box that allows you fill in the items in the
list box
these can be fully edited later in code if you need to
8-)
"Kannan" <an*******@discussions.microsoft.com> wrote in message
news:7F**********************************@microsof t.com... hi, thanks for your quick response. But my question is related to design time. Is it possible can we do it in design time without using datasource
property. In VB, I have used Item data and value data property. similarly what is
available in C# combo box (without using datasource property)? please let me know.
thanks, Kannan
----- gary hitch wrote: -----
it's very easy - ex :
ComboBox cb = new ComboBox(); string s = "hi"; cb.Items.Add( s ); // or cb.Items.AddRange( anObjectArray );
where anObjectArray is an array of System.Object based objects such
as strings etc.
;-)
"Kannan" <an*******@discussions.microsoft.com> wrote in message news:C2**********************************@microsof t.com... > hi, > Currently I am working in C# windows application. I am trying to
fill combo box with values. > We have to always use datasource property for filling values in
Combo box?? > In VB, normally i have used Item data property and display data
property. > We can't use this similar method in C#?? please let me know. >> thankjs, > Kannan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: vgrssrtrs |
last post by:
<html>
<head>
<script language="JavaScript">
<!--
/*
*** Multiple dynamic combo boxes
*** by Mirko Elviro, 9 Mar 2005
***
***Please do not remove this comment
|
by: Heather |
last post by:
Hi
I am desparately looking for advice in relation to storing the results
after selecting items from two combo boxes on a Referral form. The
first combo box 'ctl Type' displays a full list of Agency Types, then
the 2nd combo box displays a list of Organisations, depending upon the
Agency Type Selected.
The first combo box 'ctlType'...
|
by: Support4John |
last post by:
a2k (9.0.6926) SP-3 Jet 4.0 SP-7
I have a form with combo box field that allows the user to select from
the combo box or type in the field value that may or maynot be in the
combo box field.
In the After Update Event of the combo box field how can I tell if the
field value was selected from open combo box or typed in by the user?
...
|
by: Jeff Mason |
last post by:
I'm observing some strange behavior when I use a bound combo box in conjunction with
the combo's anchor property. I define a form which contains just a textbox and a
combo box. The text box is placed before the combo in taborder, and is there only so
the focus will go someplace other than the combo box when the form is displayed.
In the form...
|
by: hmiller |
last post by:
Hey everyone,
I am having a hell of a time trying to set this menu system up. Here's
what I'm trying to do.
Combo Box One; is populated by names under properties "row source"
"Phase 1" through "Phase 10" (there are 10 Phases I want to sort from)
Once the phase has been selected a second combo box would populate.
| |
by: Edwinah63 |
last post by:
Hi everyone,
Please let there be someone out there who can help.
I have two BOUND combo boxes on a continuous form, the second being
dependent on the first. I have no problem getting the second combo to
change depending on what values the user selects in the first box, it's
just that every time the user changes the first combobox, the...
|
by: kiranmn75 |
last post by:
I want to dynamically populate a combo box through javascript. Data is
coming from a array. Sometimes data list may contain items in excess of
2000.
Explorer takes more than 5 seconds to populate the combo (for a list of
2500).
Can anybody optimize the code. I tried Duffs devise instead of 'for
loop', but no improvement.
|
by: Dave |
last post by:
I want to put the information that the user selects in my combo boxes
into a subform that lies on the same form as the combo boxes.
Thanks for your help already,
Dave
|
by: biganthony via AccessMonster.com |
last post by:
Hi,
I decided to install Office 2003 Service Pack 3 on my home computer to test
(in full knowledge that there may be some issues with it). After installation,
I have noticed that with a small database I wrote for home, the combo boxes
and listboxes no longer display the bound column. For example, on a form I
have a combo box based on a...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |