public partial class Form1 : Form
{
ObservableCollection<CountryInfo> countryInfoCollection = new ObservableCollection<CountryInfo>();
public Form1()
{
InitializeComponent();
sfListView1.DataSource = GetDataSource();
sfListView1.DisplayMember = "CountryName";
ObservableCollection<CountryInfo> GetDataSource()
{
countryInfoCollection.Add(new CountryInfo() { CountryName = "China", Continent = "Asia" });
countryInfoCollection.Add(new CountryInfo() { CountryName = "India", Continent = "Asia" });
countryInfoCollection.Add(new CountryInfo() { CountryName = "Japan", Continent = "Asia" });
countryInfoCollection.Add(new CountryInfo() { CountryName = "Malaysia", Continent = "Asia" });
countryInfoCollection.Add(new CountryInfo() { CountryName = "Singapore", Continent = "Asia" });
return countryInfoCollection;
}
}
private void button1_Click(object sender, EventArgs e)
{
countryInfoCollection.Add(new CountryInfo() { CountryName = "NewCountry1", Continent = "Number1" });
}
} |
Hi, is it possible to get the the reply from Niranjan Kumar on is converted into VB.NET? I've tried online converters but none produce a compeltely useable conversion.
Thanks in advance.
Hi Paul,
You can find the
Converted VB.NET code below. Please let us know if you want any further
assistance.
Public Class Form1
Private countryInfoCollection As New ObservableCollection(Of CountryInfo)()
Public Sub New()
InitializeComponent()
sfListView1.DataSource = GetDataSource()
sfListView1.DisplayMember = "CountryName"
End Sub
Private Function GetDataSource() As ObservableCollection(Of CountryInfo)
countryInfoCollection.Add(New CountryInfo() With {.CountryName = "China", .Continent = "Asia"})
countryInfoCollection.Add(New CountryInfo() With {.CountryName = "India", .Continent = "Asia"})
countryInfoCollection.Add(New CountryInfo() With {.CountryName = "Japan", .Continent = "Asia"})
countryInfoCollection.Add(New CountryInfo() With {.CountryName = "Malaysia", .Continent = "Asia"})
countryInfoCollection.Add(New CountryInfo() With {.CountryName = "Singapore", .Continent = "Asia"})
Return countryInfoCollection
End Function
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
countryInfoCollection.Add(New CountryInfo() With {.CountryName = "NewCountry1", .Continent = "Number1"})
End Sub
End Class
Public Class CountryInfo
Public Property CountryName As String
Public Property Continent As String
End Class
Regards,
Madhumithan Jayapathi