|
Re: User v Custom Controls: msg#00352windows.devel.dotnet.winforms
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 |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: User v Custom Controls: 00352, Richard Heintze |
|---|---|
| Next by Date: | Outlook 2003 integration: 00352, Erick Thompson |
| Previous by Thread: | Re: User v Custom Controlsi: 00352, Richard Heintze |
| Next by Thread: | Re: Where is my User Control: 00352, Griffiths, Ian |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |