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 8910911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:48:58+00:00 2026-06-15T03:48:58+00:00

I got a problem with ListView in System.Windows.Forms, that i can’t handle it on

  • 0

I got a problem with ListView in System.Windows.Forms, that i can’t handle it on myself, begging for help or a hint where do I do wrong?
Description:
– I have a class – name it cListViewItem (‘c’ from custom), that inherits from standard ListViewItem, but stores my own data handling class. Now, after adding cListViewItem to a ListView class using ListView.items.Add( ) i don’t seem to have any control over the item’s name.
– fragments of my source (lil changed for the purpose of this post)

using System.Windows.Forms;
cListViewItem:ListViewItem
{
  // gives a basic idea
  public cListViewItem( myclass DataStorage )
  {
    // constructor only stores DataStorage to a local variable for further use;
    this._storage = DataStorage;
  }
  protected myclass _storage;
  // and there goes the fun:
  // I thought that ListView class uses .Text property when drawing items, but that is not truth
  // my idea was to 'cheat' a little with:
  new public String Text
  {
    get
    {
      // overriding a getter should be enough i thought, but i was wrong
      return( some string value from DataStorage class passed via constructor );
      // setter is not rly needed here, because data comes from this._storage class;
      // in later stages i've even added this line, to be informed whenever it's called ofc before return( ); otherwise VisualStudio would not compile
      MessageBox.Show( "Calling item's .Text property" );
      // guess what? this message box NEVER shows up;
    }
  }
}

I see that’s important to use .Text setter, but constructor is the last moment i can do it, right after creation cListViewItem is being added to ListView Items property and displayed, so there’s no place to call .Text = “” again.
My piece of code only works when I set all things in cListViewItem ‘s constructor like:

public cListViewItem( myclass DataStorage )
{
   this._storage = DataStorage;
   this.Text = DataStorage.String1;
   // and if I add subitems here, I will see em when the ListView.View property be changed  to View.Details
}

So am I blind or what? when I use cListViewItem.Text = “string” I will see ‘string’
in the ListView but when I just override .Text getter i can’t see the items 🙁

ListView class gives the flexibility of showing items the way I need. I wanted to create a class that will bind my custom data storage class with a ListView class. In the next stage of my application I want to bind a form for selected item in a ListView, that will allow me change item’s (my custom class) values. That’s why i wanted to make each ListViewItems item remembering corresponding custom data storage class.
Names shown in ListView will never be uniqe, so multiple same names all allowed, but items will differ by a id value (database-wise);
I just can’t figure out why using ListViewItem.Text setter does the job, altho ListView class does not use ListViewItem.Text getter for displaying items (my MessageBox never pops up)??
Pls help.

  • 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-06-15T03:48:59+00:00Added an answer on June 15, 2026 at 3:48 am

    The main problem here is that you are hiding the property with the new keyword. The original property is not virtual (“overwritable”) so it is NOT overwritten but shadowed.

    Read here for more information.

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

Sidebar

Related Questions

I've got problem. I'm using windows.forms ListView to show some data and I need
I've got a custom listView that I'm populating with this item layout. The problem
I've got problem with connecting to MySQL database on my freshly installed Windows 7
I got in to weird problem, I can't click on my list view... I
I've got problem with Listview in Android. Then I try to set adapter to
I've got a problem get binding working in an DataTemplate of a ListView. My
I have got the same problem for 8 days now and i hope that
I got a big problem, I used Lazy load of images in ListView to
I got a complicated problem involving a ListView and some Intents on Android: I
I am designing a Windows 8 Metro reading app, and got a problem of

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.