Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7004807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:14:48+00:00 2026-05-27T21:14:48+00:00

I have a Form with a listview. After calling Form.Show I need to update

  • 0

I have a Form with a listview. After calling Form.Show I need to update my listview. However, after Form.Show is called regardless of my listview code, it comes up empty, no columns, no data. If I move the Form.Show till after my listview code, the listview shows correctly.

Here is my listview code :

private void InitializeListView()
{
    _snapshotList.BeginUpdate();
    _snapshotList.Items.Clear();
    foreach (ISnapshot snapshot in _snapshots)
    {
         string comment = InstanceFactory<ProjectRecoveryService>.Instance.RetrieveCommentsforSnapshot(snapshot);

         string[] sub = new string[] { snapshot.Name, snapshot.Version.ToString(), snapshot.CreatedDate.ToString(), comment };
         ListViewItem item = new ListViewItem(sub);
         item.Tag = snapshot;
         this._snapshotList.Items.Add(item);
    }
    _snapshotList.EndUpdate();
    this._snapshotList.Refresh();
}

A side note, I have another Form that is very similar but has a TreeView that someone else has extended which works as desired.

Any thoughts?

EDIT 1
This form needs be a single instance. After reading this post, my Form.Show code is structured like this :

        public static RestoreSnapshotDialog GetInstance()
        {
            if (_dialog == null)
            {
                _dialog = new RestoreSnapshotDialog();
                _dialog.Show(Control.FromHandle(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle));
            }
            else
            {
                _dialog.BringToFront();
            }
            return _dialog;
        }

On a FormClosed event I set _dialog = null.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:14:49+00:00Added an answer on May 27, 2026 at 9:14 pm

    The only solution I could find was to call the Form.Show() after my listview was fully populated. So I create my own Form.Show by overriding Form.Show.

    public new void Show()
    {
        if (_showdialog)
        {
            _dialog.Show(Control.FromHandle(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle));
        }
        else
        {
            _dialog.BringToFront();
        }
    }
    

    Calling this method after my listview solves my problem. However, all my other dialogs (not using listview) work as expected with the code from the original post. Thanks to Hans Passant for leading me to this solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have below code in my Form Load event handler but the ListView doesn't
I have a window form application, and in that I have a ListView called
I have a ListView control on my form set up like this in details
I have a few listview controls on a windows form and i've assigned a
What I have going on is a listview inside of my windows form. How
I'm coding in VS2008 using C#. On my form, I have a ListView control.
I have a windows form with a listview control. I set the MultiSelect property
Hi i have a listview with diffrent columns ID, Name, Zipcode, City, Country, Phone,
I have form with dateTimeField, and ListView. ListView looks like that: final ListView<String> countryView
I have a form that contains two listview controls. When I click on each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.