Hi Aussie,
have you got any further process on this or does my suggestion in last
reply helps?
If there're anything else we can help, please feel free to post here.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| X-Tomcat-ID: 88200904
| References: <OC************ **@TK2MSFTNGP12 .phx.gbl>
<Oj************ **@TK2MSFTNGP11 .phx.gbl>
<f8************ *@TK2MSFTNGXA02 .phx.gbl>
<#2************ **@TK2MSFTNGP11 .phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From:
st*****@online. microsoft.com (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Tue, 20 Dec 2005 05:11:20 GMT
| Subject: Re: basic object question
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb
| Message-ID: <d6************ **@TK2MSFTNGXA0 2.phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.langua ges.vb
| Lines: 144
| Path: TK2MSFTNGXA02.p hx.gbl
| Xref: TK2MSFTNGXA02.p hx.gbl microsoft.publi c.dotnet.langua ges.vb:309335
| NNTP-Posting-Host: tomcatimport2.p hx.gbl 10.201.218.182
|
| Thanks for your respones Aussie,
|
| The problems is that you didn't set the DisplayMember or ValueMember to
the
| correct string name of the Property you want to bind. Here is a simple
| example which bind a combobox to an Array of custom class objects:
|
| ======custom class==========
| Public Class CustomerClass
| Private _id As Long
| Private _name As String
| Private _level As Integer
|
| Public Sub New()
|
| End Sub
|
| Public Sub New(ByVal id As Long, ByVal name As String, ByVal level As
| Integer)
| _id = id
| _name = name
| _level = level
|
| End Sub
|
| Public Property ID() As Long
| Get
| Return _id
| End Get
|
| Set(ByVal Value As Long)
| _id = Value
| End Set
| End Property
|
| Public Property Name() As String
| Get
| Return _name
| End Get
| Set(ByVal Value As String)
| _name = Value
| End Set
| End Property
|
| Public Property Level() As Integer
| Get
| Return _level
| End Get
| Set(ByVal Value As Integer)
| _level = Value
| End Set
| End Property
| End Class
| =============== =============== ====
|
|
|
| =========databi nding========== =
| Private Sub InputForm_Load( ByVal sender As System.Object, ByVal e As
| System.EventArg s) Handles MyBase.Load
|
| Bind_cbCustomer ()
|
| End Sub
|
| Private Sub Bind_cbCustomer ()
|
| Dim customers() As CustomerClass
| ReDim customers(15)
|
|
| Dim i As Integer
|
| For i = 1 To customers.Lengt h
|
| Dim cu As New CustomerClass
| cu.ID = i
| cu.Name = "Name_" & i
| cu.Level = i Mod 5
|
| customers(i - 1) = cu
| Next
|
|
| cbCustomers.Dis playMember = "Name"
| cbCustomers.Val ueMember = "ID"
| cbCustomers.Dat aSource = customers
|
|
| End Sub
| =============== =========
|
| Hope helps. Thanks,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure!
www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
|
|
|
|
| --------------------
| | From: "Aussie Rules" <Au*********@no spam.nospam>
| | References: <OC************ **@TK2MSFTNGP12 .phx.gbl>
| <Oj************ **@TK2MSFTNGP11 .phx.gbl>
| <f8************ *@TK2MSFTNGXA02 .phx.gbl>
| | Subject: Re: basic object question
| | Date: Mon, 19 Dec 2005 23:22:51 -0000
| | Lines: 90
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| | X-RFC2646: Format=Flowed; Original
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| | Message-ID: <#2************ **@TK2MSFTNGP11 .phx.gbl>
| | Newsgroups: microsoft.publi c.dotnet.langua ges.vb
| | NNTP-Posting-Host: ACBCEE63.ipt.ao l.com 172.188.238.99
| | Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP11.phx. gbl
| | Xref: TK2MSFTNGXA02.p hx.gbl microsoft.publi c.dotnet.langua ges.vb:309325
| | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb
| |
| | Hi,
| |
| | The following code :
| |
| | For Each pRow In dsName.Tables(" Property").Rows
| |
| | Dim oObject As New clsProperty
| |
| | oObject.intProp ertyId = pRow("Property_ ID")
| |
| | oObject.strProp erty_Address1 =
DBTextToString( pRow("Property_ address1"))
| & "
| | " & DBTextToString( pRow("PostCode" ))
| |
| | oObject.strProp ertyPrice = DBTextToString( pRow("Property_ Price"))
| |
| | cboProperty.Dis playMember = oObject.strProp erty_Address1
| |
| | cboProperty.Ite ms.Add(oObject)
| |
| | Next
| |
| |
| | Produces a drop down list that contains 'ProjectName.Cl assName'
| |
| | What am I doing wrong here ?
| |
| |
| |
| |
| | "Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
| | news:f8******** *****@TK2MSFTNG XA02.phx.gbl...
| | > Hi Aussie,
| | >
| | > I agree with Mattias, for the ComboBox control, we can use the
| | > "DisplayMem ber" to specify which property used to bind to ListItem's
| Text
| | > property, e.g:
| | >
| | > Private Sub BindComboBox()
| | > ComboBox1.DataS ource = DataSet1.Tables ("Suppliers" )
| | > ComboBox1.Displ ayMember = "ProductNam e"
| | > End Sub
| | >
| | > Also, here is a kb article which provide detailed description on .net
| | > winform databinding:
| | >
| | > #Roadmap for Windows Forms data binding
| | >
http://support.microsoft.com/?id=313482
| | >
| | > Hope helps. Thanks,
| | >
| | > Steven Cheng
| | > Microsoft Online Support
| | >
| | > Get Secure!
www.microsoft.com/security
| | > (This posting is provided "AS IS", with no warranties, and confers no
| | > rights.)
| | >
| | >
| | > --------------------
| | > | From: Mattias Sjögren <ma************ ********@mvps.o rg>
| | > | Subject: Re: basic object question
| | > | Date: Mon, 19 Dec 2005 01:41:19 +0100
| | > | References: <OC************ **@TK2MSFTNGP12 .phx.gbl>
| | > | X-Newsreader: Forte Agent 3.0/32.763
| | > | MIME-Version: 1.0
| | > | Content-Type: text/plain; charset=ISO-8859-1
| | > | Content-Transfer-Encoding: 8bit
| | > | Message-ID: <Oj************ **@TK2MSFTNGP11 .phx.gbl>
| | > | Newsgroups: microsoft.publi c.dotnet.langua ges.vb
| | > | NNTP-Posting-Host: 85.8.3.112
| | > | Lines: 1
| | > | Path:
TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP11.phx. gbl
| | > | Xref: TK2MSFTNGXA02.p hx.gbl
| microsoft.publi c.dotnet.langua ges.vb:309159
| | > | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb
| | > |
| | > | >How to I set that parameter to be the one shown inthe drop down
| | > |
| | > | Set the Combobox' DisplayMember property to "fulladdres s".
| | > |
| | > |
| | > | Mattias
| | > |
| | > | --
| | > | Mattias Sjögren [C# MVP] mattias @ mvps.org
| | > |
http://www.msjogren.net/dotnet/ |
http://www.dotnetinterop.com
| | > | Please reply only to the newsgroup.
| | > |
| | >
| |
| |
| |
|
|