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.public.dotnet.languages.vb
| Message-ID: <d6**************@TK2MSFTNGXA02.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.vb
| Lines: 144
| Path: TK2MSFTNGXA02.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.languages.vb:309335
| NNTP-Posting-Host: tomcatimport2.phx.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
| ==================================
|
|
|
| =========databinding===========
| Private Sub InputForm_Load(ByVal sender As System.Object, ByVal e As
| System.EventArgs) 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.Length
|
| Dim cu As New CustomerClass
| cu.ID = i
| cu.Name = "Name_" & i
| cu.Level = i Mod 5
|
| customers(i - 1) = cu
| Next
|
|
| cbCustomers.DisplayMember = "Name"
| cbCustomers.ValueMember = "ID"
| cbCustomers.DataSource = 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*********@nospam.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.public.dotnet.languages.vb
| | NNTP-Posting-Host: ACBCEE63.ipt.aol.com 172.188.238.99
| | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP11.phx.gbl
| | Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.languages.vb:309325
| | X-Tomcat-NG: microsoft.public.dotnet.languages.vb
| |
| | Hi,
| |
| | The following code :
| |
| | For Each pRow In dsName.Tables("Property").Rows
| |
| | Dim oObject As New clsProperty
| |
| | oObject.intPropertyId = pRow("Property_ID")
| |
| | oObject.strProperty_Address1 =
DBTextToString(pRow("Property_address1"))
| & "
| | " & DBTextToString(pRow("PostCode"))
| |
| | oObject.strPropertyPrice = DBTextToString(pRow("Property_Price"))
| |
| | cboProperty.DisplayMember = oObject.strProperty_Address1
| |
| | cboProperty.Items.Add(oObject)
| |
| | Next
| |
| |
| | Produces a drop down list that contains 'ProjectName.ClassName'
| |
| | What am I doing wrong here ?
| |
| |
| |
| |
| | "Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
| | news:f8*************@TK2MSFTNGXA02.phx.gbl...
| | > Hi Aussie,
| | >
| | > I agree with Mattias, for the ComboBox control, we can use the
| | > "DisplayMember" to specify which property used to bind to ListItem's
| Text
| | > property, e.g:
| | >
| | > Private Sub BindComboBox()
| | > ComboBox1.DataSource = DataSet1.Tables("Suppliers")
| | > ComboBox1.DisplayMember = "ProductName"
| | > 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.org>
| | > | 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.public.dotnet.languages.vb
| | > | NNTP-Posting-Host: 85.8.3.112
| | > | Lines: 1
| | > | Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP11.phx.gbl
| | > | Xref: TK2MSFTNGXA02.phx.gbl
| microsoft.public.dotnet.languages.vb:309159
| | > | X-Tomcat-NG: microsoft.public.dotnet.languages.vb
| | > |
| | > | >How to I set that parameter to be the one shown inthe drop down
| | > |
| | > | Set the Combobox' DisplayMember property to "fulladdress".
| | > |
| | > |
| | > | Mattias
| | > |
| | > | --
| | > | Mattias Sjögren [C# MVP] mattias @ mvps.org
| | > |
http://www.msjogren.net/dotnet/ |
http://www.dotnetinterop.com
| | > | Please reply only to the newsgroup.
| | > |
| | >
| |
| |
| |
|
|