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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:39:42+00:00 2026-05-26T15:39:42+00:00

I need to have multiple lines in a cell, so I use DataGridViewTextBoxColumn.DefaultCellStyle.WrapMode =DataGridViewTriState.True.

  • 0

I need to have multiple lines in a cell, so I use DataGridViewTextBoxColumn.DefaultCellStyle.WrapMode =DataGridViewTriState.True.
I add columns (datagridviewtextboxcolumn) in designer. Then bound datagridview to a table which has exact the same columns as datagridview. Then I find that datagridview has duplicate columns: the first column is empty (which I guess is added through designer), the second column is filled with data from table. My question is how to correctly allow multi-lines and bound to a table at the same time?

In Designer

Friend WithEvents DGV As New System.Windows.Forms.DataGridView
Friend WithEvents columnClient As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents columnAccount As System.Windows.Forms.DataGridViewTextBoxColumn
Me.DGV.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.columnClient, Me.columnAccount})
Dim cellStyle As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle
cellStyle.WrapMode = DataGridViewTriState.True
Me.columnClient.DefaultCellStyle = cellStyle
Me.columnAccount.DefaultCellStyle = cellStyle

Then I bound datagridview to a table

DGV.DataSource = m_table
m_table.Columns.Add(columnClient)
m_table.Columns.Add(columnAccount)

Dim rowText As DataRow = m_table.NewRow
Dim strBaseKey As String="base key"
Dim accountkey As String="account key"
rowText(columnClient) = strBaseKey
rowText(columnAccount) = accountKey

Add: I just deleted columns in designer and it works now.

  • 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-26T15:39:43+00:00Added an answer on May 26, 2026 at 3:39 pm

    The solution is simple: just do not add columns to datagridview in designer; instead add columns to table and then bound datagridview to table. To enable multi-lines in datagridview, set the column.DefaultCellStyle.WrapMode=DataGridViewTriState.True

    DGV.DataSource = m_table 
    m_table.Columns.Add(columnClient) 
    m_table.Columns.Add(columnText) 
    
    Dim rowText As DataRow = m_table.NewRow 
    rowText(columnClient) = "Bob"
    rowText(columnAccount) ="Account1" & Encironment.Newline & "Account 2"
    
    DGVTable.Columns(columnText).DefaultCellStyle.WrapMode = DataGridViewTriState.True
    

    The datagridview will show:

       columnClient     columnAccount
       Bob              Account1
                        Account2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an input string containing multiple lines(demarcated by \n). I need to search
I have a large string (multiple lines) I need to find numbers in with
I have a std::string with multiple lines and I need to read it line
I need to have multiple forms in the same webpage, all of them POSTing
Hello I need to have multiple language support of my django admin application.I can
I have multiple threads who all need to write to the same Dictionary. I
I have multiple threads (C# application running on IIS) running that all need to
The problem is this: I have multiple competing threads (100+) that need to access
I have need to return multiple results from a subquery and have been unable
Basically multiple instances of our application will be launched but they need to have

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.