3 Replies - 493 Views - Last Post: 28 August 2015 - 07:08 AM Rate Topic: -----

#1 PhroznLTD   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 05-October 09

Extend a control to allow custom properties (not visible)

Posted 27 August 2015 - 07:06 PM

What I want to achieve is simple sounding (and maybe simple to execute). Say I have a DataGridView, or a ListView. Imagine the DataTable is as follows:

LINK	TITLE
www.blah.com	Blah's Homepage
www.boo.com	Boo's Homepager
www.foo.com	Foo's Homepage


If I wanted to say store other data pertaining to these entries, how would I do it? I've seen the tag property used, but what if I want multiple data points? Do I extend the class, if so, can you point me to a tutorial/guide? Thank you for your help!

EDIT: Keeping in mind, I do not want to actually display the other data.

Is This A Good Question/Topic? 0
  • +

Replies To: Extend a control to allow custom properties (not visible)

#2 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7447
  • View blog
  • Posts: 25,085
  • Joined: 05-May 12

Re: Extend a control to allow custom properties (not visible)

Posted 27 August 2015 - 07:48 PM

Tag will take any object or struct, so you can create an object or struct with all the values you want to store and then assign it to the Tag property.
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw   User is offline

  • palpable absurdity
  • member icon

Reputation: 6905
  • View blog
  • Posts: 28,565
  • Joined: 12-December 12

Re: Extend a control to allow custom properties (not visible)

Posted 28 August 2015 - 01:10 AM

It is, or should be, possible to create a wrapper class with additional properties, or to add new columns to a DataTable. I don't have tutorials to refer you to, just letting you know that these are possible approaches that you could investigate.

Of course, all this new data will only exist temporarily, so you should consider whether the data store itself should be modified to allow persistence of this data, or some of it.

This post has been edited by andrewsw: 28 August 2015 - 02:30 AM

Was This Post Helpful? 0
  • +
  • -

#4 Curtis Rutland   User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5106
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: Extend a control to allow custom properties (not visible)

Posted 28 August 2015 - 07:08 AM

If you've already got a datatable, it's trivial to add a new column then populate it. The question is, where is the additional data coming from? How will you match it up to the existing data. For that matter, where is the original data coming from?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1