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

  • Home
  • SEARCH
  • 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 6826199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:07:07+00:00 2026-05-26T22:07:07+00:00

Is it possible to allow more than one object in a cell in a

  • 0

Is it possible to allow more than one object in a cell in a DataGridView?

I want to display a Group in the first column and then in the column next to it I want to display all of the users that are in that group but in one cell (the cell next to the group name). And this can not be string manipulation because I need to be able to click on each of the users and drag and drop them around. I am using a DataGridview linked up to a SQL query database.

I am using Visual Basic with Visual Studio 2010.

  • 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-26T22:07:08+00:00Added an answer on May 26, 2026 at 10:07 pm

    Unfortunately you cannot do this in the DataGridView. You can, however, create a table that looks something like this:

    GROUP   USER
    ------  -----
    
    Group1  User1
    Group1  User2
    Group1  User3
    Group2  UserA
    Group2  UserB
    

    Once you do this, then you can handle the CellFormatting event of the DataGridView and set the e.FormattedValue to String.Empty if the value of the cell above matches. Then your table will “look” like:

    GROUP   USER
    ------  -----
    
    Group1  User1
            User2
            User3
    Group2  UserA
            UserB
    

    This is pretty much what you are looking for. If you want the gridlines to go away, you can instead handle the DataGridView’s CellPainting event to draw proper borders, center text, etc.

    UPDATE: Here’s an example of using the CellFormatting event to hide the contents of a cell. In this example, I am just using a List as my datasource, but you can substitute this for your SQL Data Source, DataTable, etc.

    public partial class Form1 : Form
    {
        private List<GroupUserRow> _rows = new List<GroupUserRow>();
    
        public Form1()
        {
            InitializeComponent();
    
            _rows.Add(new GroupUserRow { Group = "Group1", User = "User1" });
            _rows.Add(new GroupUserRow { Group = "Group1", User = "User2" });
            _rows.Add(new GroupUserRow { Group = "Group1", User = "User3" });
            _rows.Add(new GroupUserRow { Group = "Group2", User = "UserA" });
            _rows.Add(new GroupUserRow { Group = "Group2", User = "UserB" });
    
            dataGridView1.DataSource = _rows;
        }
    
        private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.RowIndex >= 0 && e.ColumnIndex == 0)
            {
                int prevRowIndex = e.RowIndex - 1;
                if (prevRowIndex >= 0 && dataGridView1[0, prevRowIndex].Value == e.Value)
                {
                    //this just "hides" the value from the screen, the value is not
                    //removed from the cell
                    e.Value = String.Empty;
                    e.FormattingApplied = true;
                }
            }
        }
    
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
            {
                MessageBox.Show("This cell's value is: " + dataGridView1[e.ColumnIndex, e.RowIndex].Value);
            }
        }
    
    }
    
    public class GroupUserRow
    {
        public string Group { get; set; }
        public string User { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to have a single stream and have more than one XmlWriter
I would like to allow access to a particular method to more than one
I need to not allow more than one period ( . ) in the
I need to specify more than one condition for visibilty visible={data.allow && data.open} However,
Is it possible to allow embed, object, and param HTML tags with HTMLPurifier? I'm
Is it possible to allow a user to add and edit column names for
Is it possible to prevent stack allocation of an object and only allow it
Is it possible to allow users to drag and drop items in mobile safari?
How is it possible to allow a user to create a webpage containing some
Is it possible to allow a user to select text in a silverlight text

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.