SfListView - Add items manually
Hello,
SIGN IN To post a reply.
8 Replies
NI
Ninja
Syncfusion Team
February 7, 2020 11:24 AM UTC
Hi Fred,
Thanks for contacting Syncfusion support.
We have checked your query “Need to know whether gradient panel has property to show shadow border”. Currently we do not have support to meet your requirement and we are checking for work-around to meet your requirement and will update you on 11th February 2020.
Regards,
Niranjan Kumar
DF
Dinis Ferreira
February 7, 2020 12:02 PM UTC
Hello,
I believe this reply is in the wrong thread.
Thanks
NI
Ninja
Syncfusion Team
February 7, 2020 12:57 PM UTC
Hi Dinis,
Sorry for the inconvenience caused.
We have checked your query “Need to add items in SfListItems manually in code behind without using DataSource”. Currently we do not have this support. So we are validating this request with internal team and will let you know on 11th February 2020.
Regards,
Niranjan Kumar
NI
Ninja
Syncfusion Team
February 11, 2020 12:00 PM UTC
Hi Dinis,
Thanks for your patience.
If your data source is of type ObservableCollection, SfListView will be automatically updated when there is any change in that collection. So, if you want to add an item, you can directly add it to the data source, provided it is of type ObservableCollection.
C#:
|
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" });
}
} |
Regards,
Niranjan Kumar
DF
Dinis Ferreira
February 11, 2020 01:00 PM UTC
Thanks.
NI
Ninja
Syncfusion Team
February 12, 2020 04:38 AM UTC
Hi Dinis,
Thanks for your update.
We are glad to know that the reported query has been resolved at your end. Please let us know if you require further assistance.
Regards,
Niranjan Kumar Gopalan
PC
Paul Casson
July 11, 2023 03:35 PM UTC
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.
MJ
Madhumithan Jayapathi
Syncfusion Team
July 12, 2023 01:35 PM UTC
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
SIGN IN To post a reply.
- 8 Replies
- 4 Participants
-
DF Dinis Ferreira
- Feb 6, 2020 05:36 PM UTC
- Jul 12, 2023 01:35 PM UTC