Click here to Skip to main content
15,891,907 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello..i havea problem??


I want when i register someone in datagridview

example

id. name. date
1 customer1 x.x.xxx
customer1 x.x.xxx
customer1 x.x.xxxx

and customer1. must have multiple cells ????

What I have tried:

I have selected wrap mode to true
nothin else
Posted
Updated 29-Dec-16 4:03am

I think, you mean Columns - not Rows ...
In this case it could be made like this :
VB
my_DataGridView.Rows.Add ( myID , myName , myDate.tostring ) 
 
Share this answer
 
v2
If I understand you correctly, you want to wrap multiple data items in a single datagridview cell, right?
First, you have to add a newline between every two items, in vb, that will be:
VB.NET
vbCrLf
or
C#
Environment.NewLine

Next, make your datagridview cells wrappable and rows autosizing, e.g.
DataGridView1.DefaultCellStyle.WrapMode = DataGridViewTriState.True
DataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells

Putting them together, a demo is shown below:
VB.NET
Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim dt As New DataTable

        dt.Columns.Add("Combined", GetType(String))
        dt.Columns.Add("id", GetType(Integer))
        dt.Columns.Add("Name", GetType(String))

        dt.Rows.Add("25" & vbCrLf & "James", "25", "James")
        dt.Rows.Add("50" & vbCrLf & "Mary", "50", "Mary")

        DataGridView1.DefaultCellStyle.WrapMode = DataGridViewTriState.True
        DataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
        DataGridView1.DataSource = dt
    End Sub
End Class
 
Share this answer
 
v2
Yes.. already works for nvarch(MAX)

how to work with .. date . multiple datas??
 
Share this answer
 
Know i want to know how to get 3 Values += in datagridview

example .. column 1 - 23
22
87




textbox1.text = Must show me .. the total of 3 values ??
 
Share this answer
 
Comments
Ralf Meier 30-Dec-16 3:24am    
How many comments to your question do you want to post as a Solution in future ?
What you have written is a comment (or perhaps an improvement to your question ...!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900