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 ?
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.
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
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.
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.
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