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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:10:58+00:00 2026-05-11T13:10:58+00:00

I have a DataGridView with cells from a database file that contains data. Basically,

  • 0

I have a DataGridView with cells from a database file that contains data. Basically, I want to get the text from the selected cells in the DataGridView and display it in a textbox at the click of the button. The code for the button click event is:

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click     Dim SelectedThings As String = DataGridView1.SelectedCells.ToString     TextBox1.Text = SelectedThings End Sub 

However in TextBox1 I get:

System.Windows.Forms.DataGridViewSelectedCellCollection

I’m thinking it isn’t as simple as it seems. I’m a C developer just learning VB.NET.

  • 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. 2026-05-11T13:10:59+00:00Added an answer on May 11, 2026 at 1:10 pm

    DataGridView.SelectedCells is a collection of cells, so it’s not as simple as calling ToString() on it. You have to loop through each cell in the collection and get each cell’s value instead.

    The following will create a comma-delimited list of all selected cells’ values.

    C#

    TextBox1.Text = ''; bool FirstValue = true; foreach(DataGridViewCell cell in DataGridView1.SelectedCells) {     if(!FirstValue)     {         TextBox1.Text += ', ';     }     TextBox1.Text += cell.Value.ToString();     FirstValue = false; } 

    VB.NET (Translated from the code above)

    TextBox1.Text = '' Dim FirstValue As Boolean =  True  Dim cell As DataGridViewCell For Each cell In DataGridView1.SelectedCells     If Not FirstValue Then         TextBox1.Text += ', '     End If     TextBox1.Text += cell.Value.ToString()     FirstValue = False Next 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 120k
  • Answers 120k
  • 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 I tried to find some control templates or solutions for… May 12, 2026 at 12:13 am
  • Editorial Team
    Editorial Team added an answer try this: require 'rubygems' require 'ramaze' class PutController < Ramaze::Controller… May 12, 2026 at 12:13 am
  • Editorial Team
    Editorial Team added an answer 1 . The plus sign is the unary + operator.… May 12, 2026 at 12:12 am

Related Questions

I have a dataset with multiple tables. One table in particular has one record
I am implementing a Data Access Layer (DAL), which is basically a set of
I have a DataGridView that is populated with 4 columns and multiple rows of
I have a DataGridView where I manage manually the focused cells when navigating with

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.