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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:43:35+00:00 2026-06-14T14:43:35+00:00

In my project, I’m filling the dataGridView from dataSet (binding the DataGridView to DataSet

  • 0

In my project, I’m filling the dataGridView from dataSet (binding the DataGridView to DataSet). The first column in dataGridView must be LinkLabels which I’m trying to get in the below code.

dgvMain.DataSorce = ds.Tables[0];

I tried: (not working)

DataGridViewLinkCell lnkCell = new DataGridViewLinkCell();
foreach (DataGridViewRow row in dgvMain.Rows)
{
    row.Cells[0] = lnkCell; // (ERROR) Cell provided already belongs to a grid. This operation is not valid.
}

also tried

for (int intCount = 0; intCount < dgvMain.Rows.Count; intCount++)
{
    dgvMain.Rows[intCount].Cells[0] = lnkCell; // (ERROR) Cell provided already belongs to a grid. This operation is not valid.
}

The above attempts are adding linkLabel to the first cell only not all the cells in that column
When I debugged my code, I concluded that after adding the linkLabel to the first cell exception error is coming which I mentioned in the above code, which is making the code not to run properly.

Please give me any suggestions, what should I do?

EDIT: Though it is not the correct way but I gave the column cells a look like Linklabel by writing the below code:

            foreach (DataGridViewRow row in dgvMain.Rows)
            {
                row.Cells[1].Style.Font = new Font("Consolas", 9F, FontStyle.Underline);
                row.Cells[1].Style.ForeColor = Color.Blue;
            }

Now the problem is that I cant add Hand like cursor to the only column cells(which is visible for LinkLabels). Is there anyway to achieve it? (I need answer for both questions, mainly the first one).

  • 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-14T14:43:36+00:00Added an answer on June 14, 2026 at 2:43 pm

    This is what I’ve been doing when I’m changing type of the cell.
    Use your “also tried” loop and change:

    dgvMain.Rows[intCount].Cells[0] = lnkCell;
    

    To:

    foreach (DataGridViewRow r in dgvMain.Rows)
      {
          DataGridViewLinkCell lc =  new DataGridViewLinkCell();
          lc.Value = r.Cells[0].Value;
          dgvMain[0, r.Index] = lc;
      }
    

    Second Question:
    Set the CellMouseLeave and CellMouseMove of the dgvMain events to the following.

    private void dataGridView1_CellMouseLeave(object sender, DataGridViewCellEventArgs e)
    {
        if (e.ColumnIndex == 1)
        {
            this.Cursor = Cursors.Default;
        }
    }
    
    private void dataGridView1_CellMouseMove(object sender, DataGridViewCellMouseEventArgs e)
    {
        if (e.ColumnIndex == 1)
        {
            this.Cursor = Cursors.Hand;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Project: http://development.legendarylion.com/ Website in development. Trying to get a .png to show up over
Project: I am having a button that toggles the column length from 3 to
Project has_many :items Item belongs_to :project I'm trying to get the projects sorted by
This project was coped almost exacatly from the example on the admob page but
Project was working on PC number 1. Copied project to external drive and trying
Our project's template html has a quirks declaration,which is <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML
My project demands and upgrade from groovy 1.7.2 to 1.8.x stable release, there are
Every project invariably needs some type of reporting functionality. From a foreach loop in
My project is currently using a svn repository which gains several hundred new revisions
Project: ASP.NET 3.5 with C# I have this much :- A table which used

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.