|
Re: Binding Combobox to ArrayList (was User v Custom Controls): msg#00392windows.devel.dotnet.winforms
The Class Library does a pretty good job of explaining which interfaces a class must support in order to be a source for a combo box. Regards, J. Vince Pacella / OOCL Chicago 10.30 - 7.00 Central Tel - 773-399-6218 Fax - 773-867-5050 Cargo Tracking Online at: www.cargosmart.com and www.oocl.com -----Original Message----- From: Richard Heintze [mailto:sieg_heintze@xxxxxxxxx] Sent: Thursday, February 26, 2004 9:20 AM To: DOTNET-WINFORMS@xxxxxxxxxxxxxxxxxxx Subject: Re: [DOTNET-WINFORMS] Binding Combobox to ArrayList (was User v Custom Controls) Andy, Yes, please send me the code. Others, Can I stick an integer in a combobox as a value member? I think that might have been one problem. I notice that VB will let me store integers in the value column too (I thought this was a C++ problem, but I had the same problem with VB). I don't get an error untill I select an item with the "combobox1.SelectedValue" property. Hmmm... I wish I could do this ArrayList/combobox databind with less code. Creating a special class for every combobox I want to define is kinda of a pain. Javascript/HTML programmers can do this (populate a combobox with key/value pairs) with much greater ease than WinForms programmers can. Incidently, Is there a more efficient data structure we can use for large lists? If we pass it an ArrayList, does this mean we are doing linear searches? Can we bind a combobox to something more efficient like a hash table or binary tree table? Thanks, Sieg > --- Andy Schott <andy@xxxxxxxxxxxxx> wrote: > > Richard, > > One problem that I'm seeing (I think - I'm no > where > > near a managed C++ > > expert) is that you're not using managed strings. > > Whenever you want a hard > > coded string to be a managed string, you need to > > prefix it with an 'S'. For > > example: > > State __gc* pState = new State(S"WA", > > S"Washington"); > > > > That creates a new States passing it the managed > > strings containing "WA" and > > "Washington". > > > > I quickly converted the VB code that you posted, > and > > it worked fine. If you > > want me to, I'd be happy to e-mail you the code > that > > I wrote (it may not be > > the best, but it works). > > > > Andy > > > > -----Original Message----- > > From: Discussion forum for developers using > Windows > > Forms to build apps and > > controls > > [mailto:DOTNET-WINFORMS@xxxxxxxxxxxxxxxxxxx] On > > Behalf Of Richard > > Heintze > > Sent: Wednesday, February 25, 2004 4:19 PM > > To: DOTNET-WINFORMS@xxxxxxxxxxxxxxxxxxx > > Subject: Re: [DOTNET-WINFORMS] User v Custom > > Controls > > > > > > > > Where's the problem? > > > > > > ArrayList __gc * l = new ArrayList(); > > > l->Add(S"Test1"); > > > l->Add(S"Test2"); > > > l->Add(S"Test3"); > > > comboBox1->DataSource = l; > > > > > > > Can someone help me translate this into C++? When > I > > tried, the combobox > > choked on the strings I gave it for the value and > > display members. > > > > Public Structure State > > Private m_shortName, m_longName As String > > > > Public Sub New(ByVal longName As String, ByVal shortName As > > String) > > Me.m_shortName = shortName > > Me.m_longName = longName > > End Sub > > > > Public ReadOnly Property ShortName() As String > > Get > > Return m_shortName > > End Get > > End Property > > > > Public ReadOnly Property LongName() As String > > Get > > Return m_longName > > End Get > > End Property > > End Structure > > > > Private States() As State = {New State("Alabama", > > "AL"), ..., New > > State("Wyoming", "WY")} > > > > comboBoxState.DataSource=States > > comboBoxState.DisplayMember="LongName" > > > > > > > > > > > > From > > > http://samples.gotdotnet.com/quickstart/aspplus/default.aspx?url=%2fquic ksta > > rt%2fwinforms%2fdoc%2fWinFormsData.aspx > > > > > > __________________________________ > > Do you Yahoo!? > > Yahoo! Mail SpamGuard - Read only the mail you > want. > > http://antispam.yahoo.com/tools > > > __________________________________ > Do you Yahoo!? > Get better spam protection with Yahoo! Mail. > http://antispam.yahoo.com/tools > __________________________________ Do you Yahoo!? Get better spam protection with Yahoo! Mail. http://antispam.yahoo.com/tools IMPORTANT NOTICE Email from OOCL is confidential and may be legally privileged. If it is not intended for you, please delete it immediately unread. The internet cannot guarantee that this communication is free of viruses, interception or interference and anyone who communicates with us by email is taken to accept the risks in so doing. Without limitation, OOCL and its affiliates accept no liability whatsoever and howsoever arising in connection with the use of this email. Under no circumstances shall this email constitute a binding agreement to carry or for provision of carriage services by OOCL, which is subject to the availability of carrier's equipment and vessels and the terms and conditions of OOCL's standard bill of lading which is also available at http://www.oocl.com. |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: User v Custom Controls: 00392, Craig Larsen |
|---|---|
| Next by Date: | Handling lots of menu entries: 00392, Richard Heintze |
| Previous by Thread: | Re: Binding Combobox to ArrayList (was User v Custom Controls)i: 00392, Richard Heintze |
| Next by Thread: | Form.Owner: 00392, Kevin Hector |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |