© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
7 replies
driftx0

ListView control not updating with data in Windows Forms application

I'm having an issue with a ListView control not updating with data in my Windows Forms application. Here's the relevant code:

// In the ProgramWindow form
public void UpdateDataListView(List<dynamic> AdvancedDataListResult)
{
// Clear the existing items in the ListView
DataListView.Items.Clear();

foreach (var rowData in AdvancedDataListResult)
{
if (rowData != null)
{
ListViewItem item = new ListViewItem();
item.Text = rowData.id?.ToString() ?? string.Empty;
item.SubItems.Add(rowData.serial_number?.ToString() ?? string.Empty);
item.SubItems.Add(rowData.deceased_name?.ToString() ?? string.Empty);
item.SubItems.Add(rowData.father_name?.ToString() ?? string.Empty);
item.SubItems.Add(rowData.sure_name?.ToString() ?? string.Empty);
item.SubItems.Add(rowData.mother_name?.ToString() ?? string.Empty);
DataListView.Items.Add(item);
}
}
DataListView.Update();
}
The UpdateDataListView method is called from another form (AdvancedSearchForm) after retrieving the data from a search operation:

// In the AdvancedSearchForm
private void AdvancedSearchBtn_Click(object sender, EventArgs e)
{
string serial_number = Advanced_SerialNumber.Text;
string deceased_name = Advanced_DeceasedName.Text;
string mother_name = Advanced_MotherName.Text;
List<dynamic> AdvancedDataListResult = search.AdvancedSearch(serial_number, deceased_name, mother_name);

Program.UpdateDataListView(AdvancedDataListResult);
this.Close();
}
The issue is that the DataListView control in the ProgramWindow form is not updating with the data from the search results, even though the UpdateDataListView method is being called with the correct data.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

❔ Windows Forms listview
C#CC# / help
4y ago
❔ Windows Forms C# application
C#CC# / help
3y ago
Problem with Updating Messages in Windows Forms (FlowLayoutPanel)
C#CC# / help
2y ago
Windows Forms Data Sources
C#CC# / help
2y ago