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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:19:07+00:00 2026-06-13T11:19:07+00:00

I am currently working on a bookmark manager application (Windows Forms), with advanced search

  • 0

I am currently working on a bookmark manager application (Windows Forms), with advanced search capabilities.

I have created a Links class, and every time a user enters a URL, I’ll create a Link object and store the details there. It currently has the properties Name, URL and Tags, where Tags is a list.

At runtime when I set the DataSource property of a gridview to the List<Links> objects, the Name and the URL show up but the tags do not.

How do I go about displaying the list of tags inside the List<Links> object in the gridview?

EDIT: Just had an idea. What if I write a function to convert the List<Links> into a DataTable, and then set the DataSource property of the DataGrid to the DataTable?

The problem with this is that everytime a change is made to the List<Links> I will have to generate the DataTable again, which does not seem ideal from a performance point of view.

EDIT 2: I wish to display each item in the list as a DataGridViewTextBox column.

Thanks,

Abijeet.

  • 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-13T11:19:08+00:00Added an answer on June 13, 2026 at 11:19 am

    Maybe this is what you want… an object that appears to have more properties that it actually has.

    The DataGridView controll supports the ComponentModel namespace so that you can create classes that appear to have properties that don’t exist. It is the same mechanism the PropertyGrid uses.

    Sample code

    This sample is a fully working windows forms class, with a form containing a DataGridView. I add some objects to is, using a list that is then set to the DataSource property.

    The objects inside that list, have no properties at all… but they use component model to describe ‘virtual’ properties to the DataGridView.

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Windows.Forms;
    
    namespace WindowsFormsApplication1
    {
        public class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
    
                this.dataGridView1.Dock = DockStyle.Fill;
            }
    
            protected override void OnLoad(EventArgs e)
            {
                base.OnLoad(e);
    
                dataGridView1.DataSource = new List<MyClass>
                        {
                          new MyClass("value 1", "value 2", "value 3"),
                          new MyClass("value 1", "value 2"),
                        };
            }
    
            class MyClass : CustomTypeDescriptor
            {
                public MyClass(params string[] tags)
                {
                    this.tags = new List<string>(tags);
                }
    
                public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
                {
                    var listProps = new List<PropertyDescriptor>();
    
                    // adding properties dynamically
                    for (int i = 0; i < tags.Count; i++)
                        listProps.Add(new PropDesc("Tag" + i, i));
    
                    return new PropertyDescriptorCollection(listProps.ToArray());
                }
    
                private List<string> tags = new List<string>();
    
                class PropDesc : PropertyDescriptor
                {
                    private int index;
    
                    public PropDesc(string propName, int index)
                        : base(propName, new Attribute[0])
                    {
                        this.index = index;
                    }
    
                    public override bool CanResetValue(object component) { return false; }
    
                    public override Type ComponentType { get { return typeof(MyClass); } }
    
                    public override object GetValue(object component)
                    {
                        if (index >= ((MyClass)component).tags.Count)
                            return null;
    
                        return ((MyClass)component).tags[index];
                    }
    
                    public override bool IsReadOnly { get { return true; } }
    
                    public override Type PropertyType { get { return typeof(string); } }
    
                    public override void ResetValue(object component) { }
    
                    public override void SetValue(object component, object value) { }
    
                    public override bool ShouldSerializeValue(object component) { return false; }
                }
            }
    
            private void InitializeComponent()
            {
                this.dataGridView1 = new DataGridView();
                ((ISupportInitialize)(this.dataGridView1)).BeginInit();
                this.SuspendLayout();
                // dataGridView1
                this.dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
                this.dataGridView1.Dock = DockStyle.Fill;
                this.dataGridView1.Location = new System.Drawing.Point(0, 0);
                this.dataGridView1.Name = "dataGridView1";
                this.dataGridView1.Size = new System.Drawing.Size(284, 262);
                this.dataGridView1.TabIndex = 1;
                // Form1
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(284, 262);
                this.Controls.Add(this.dataGridView1);
                this.Name = "Form1";
                this.Text = "Form1";
                ((ISupportInitialize)(this.dataGridView1)).EndInit();
                this.ResumeLayout(false);
    
            }
    
            private DataGridView dataGridView1;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently working on a bespoke ecommerce application using Codeigniter. I have a products table
Currently working on a little Windows Phone (7.5) application and one of the pages
Am currently working on an application that requires users to submit posts and comments
Currently working on a Spring 2.5 web application, looks as if the business has
What I have so far: I'm currently working on a Lift-based project for work.
We have a Java application under Mercurial version control. We're working on implementing a
Currently working on a project with the cloud / azure and windows phone 7,
Currently working on a project that is being developed in VS2010. I'm running Windows
Currently working on trying to figure out asynchronous submission in ColdFusion. I always have
I am currently working on a Django/Pinax application (I'm sure my question is not

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.