|
Re: Binding Combobox to ArrayList (was User v Custom Controls): msg#00387windows.devel.dotnet.winforms
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=%2fquicksta > > 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 |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Merging DataSet (Added and Unchanged): 00387, Block, Jeffrey A. (Jeff) |
|---|---|
| Next by Date: | Re: Merging DataSet (Added and Unchanged): 00387, Bill Schmidt |
| Previous by Thread: | Re: User v Custom Controlsi: 00387, Griffiths, Ian |
| Next by Thread: | Re: Binding Combobox to ArrayList (was User v Custom Controls): 00387, Vince Pacella |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |