|
-
Mar 1st, 2013, 03:32 AM
#1
Thread Starter
Member
Problem using ObjectListView in VB.net
hi,
Previously I try to learn add, edit and delete using ObjectListView in C# ( I still learn about C# )
but now I try to use it in vb net, now I'm confuse how to addobject in vb, I don't know how to change C# to vb
can someone help me how to add items to objectlistview ?
-
Mar 1st, 2013, 04:36 AM
#2
Re: Problem using ObjectListView in VB.net
The VB code will be almost exactly the same as the C# code. Given that we don't know what the C# code looks like though, we can hardly tell you what the equivalent VB looks like.
-
Mar 1st, 2013, 03:09 PM
#3
Thread Starter
Member
Re: Problem using ObjectListView in VB.net
in my C# code when I add to objectlistview I create a class to add my item to objectlistview
my code will be like this
Code:
private void button1_Click(object sender, EventArgs e)
{
people pl = new people(txtName.Text, txtAddress.Text);
objectlistview1.AddObject(pl);
}
class people
{
public people(String name, string address)
{
this.Name = name;
this.Address = address;
}
public string Name { get; set; }
public string Address { get; set; }
}
that makes me confuse how i can change it to vb.. please help me how to change it to vb or how to add item to objectlistview
-
Mar 1st, 2013, 03:48 PM
#4
Re: Problem using ObjectListView in VB.net
This conversion site gives you ...
Private Sub button1_Click(sender As Object, e As EventArgs)
Dim pl As New people(txtName.Text, txtAddress.Text)
objectlistview1.AddObject(pl)
End Sub
Private Class people
Public Sub New(name As [String], address As String)
Me.Name = name
Me.Address = address
End Sub
Public Property Name() As String
Get
Return m_Name
End Get
Set
m_Name = Value
End Set
End Property
Private m_Name As String
Public Property Address() As String
Get
Return m_Address
End Get
Set
m_Address = Value
End Set
End Property
Private m_Address As String
End Class
Looks about right to me.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Mar 1st, 2013, 07:27 PM
#5
Re: Problem using ObjectListView in VB.net
The one thing that you'd need to add to the code that dunfiddlin posted is a Handles clause to the button1_Click. It is obviously intended to be a handler for the Click event of 'button1' so you would add 'Handles button1.Click' to the method declaration.
-
Mar 2nd, 2013, 03:01 AM
#6
Thread Starter
Member
Re: Problem using ObjectListView in VB.net
thanks for the help.. the code works well for now
I never know there is a web that can convert C# to vb.. thanks again
Last edited by choco; Mar 2nd, 2013 at 03:23 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|