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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:58:53+00:00 2026-05-13T10:58:53+00:00

I’m currently working on a wrapper for a third party component (not the best

  • 0

I’m currently working on a wrapper for a third party component (not the best idea, I know) that we just purchased, a grid to be precise. Well, exposing most of the grid properties hasn’t been that hard so far… my real issue is with the rows/cells collection.

The seniors/leads don’t want the developers going crazy with everything in those, so having some sort CustomRowCollection of CustomRow objects wrapping the bare minimum of the actual grid’s RowCollection of Row objects is their idea… same goes for cells, a CustomRow object should have a CustomCellCollection of CustomCells wrapping the actual gridrow’s CellCollection of Cell objects.

Do you have any advice on how I should approach this? I can’t quite picture the design.
Thanks

  • 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-13T10:58:53+00:00Added an answer on May 13, 2026 at 10:58 am

    The CustomRowCollection is a wrapper around the RowCollection. It’s not actually a collection at all; it’s a class that implements ICollection<CustomRow> and translates each method into the appropriate method on the underlying RowCollection. For instance:

    public void Add(CustomRow r)
    {
       _RowCollection.Add(r.Row);
    }
    

    The problem with this is evident if you look at, say, the indexer:

    public CustomRow this[int i]
    {
       get { return new CustomRow(_RowCollection[i]); }
       set { _RowCollection[i] = value.Row; }
    }
    

    You’re creating a new CustomRow object every time you get a CustomRow out of the CustomRowCollection. This can cause a lot of problems. For instance, this will fail, and it really shouldn’t:

    Debug.Assert(myCustomRowCollection[0] == myCustomRowCollection[0]);
    

    There are a couple of ways around this. You can shadow the RowCollection with a private Dictionary<Row, CustomRow> field. Your indexer would then look like this:

    public CustomRow this[int i]
    {
       get
       {
          Row r = RowCollection[i];
          if (!_Dictionary.ContainsKey(r))
          {
             _Dictionary[r] = CustomRow(r);
          }
          return _Dictionary[r];
       }
       set
       {
          _Dictionary[value.Row] = value;
          RowCollection[i] = value.Row;
       }
    }
    

    This prevents you from ever creating two CustomRow objects with the same underlying Row. But it’s a lot of work, because you have to deal with keeping those collections in sync with each other. (It’s especially bad if the grid ever deletes a Row from its RowCollection without notifying you, because you’re still maintaining a reference to that Row in your dictionary and nothing short of re-synching your dictionary with the RowCollection is ever going to remove it.)

    A simpler way is to override Equals in the CustomRow class, so that two CustomRow objects are equal if their Row properties are equal. You also have to override GetHashCode so that it returns Row.GetHashCode(), which will let you use CustomRow objects as dictionary keys.

    You have to be very careful, if you do this, not to ever implement any properties in CustomRow that aren’t wrappers around properties in Row. If you ever do this, you’re introducing a situation in which this might not fail, and it always should:

    Debug.Assert(r1 == r2 && r1.Property != r2.Property);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 372k
  • Answers 372k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Update table_name SET room='', Stauts='DISPOSED' where Room='DISPOSED' OR Update table_name… May 14, 2026 at 7:22 pm
  • Editorial Team
    Editorial Team added an answer Whether or not this is valid depends on your doctype,… May 14, 2026 at 7:22 pm
  • Editorial Team
    Editorial Team added an answer First of all. you will need the RotateTransform object in… May 14, 2026 at 7:22 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.