如何在datagridview单元格VB.NET上添加多行 [英] How to add multi rows on a datagridview cell VB.NET
问题描述
你好......我有问题吗?
我想在datagridview中注册某人
example < br $> b $ b
id。名称。 date
1 customer1 xxxxx
customer1 xxxxx
customer1 xxxxxx
和customer1。必须有多个单元格????
我尝试过:
我选择了换行模式为真
nothin else
我想,你的意思是列 - 不是行...
在这种情况下,它可以像这样:
my_DataGridView.Rows.Add(myID,myName,myDate.tostring)
如果我理解正确,你想在一个datagridview单元中包装多个数据项,对吗?
首先,你必须添加一个每两个项目之间的换行符,以vb为单位,即:
vbCrLf或
Environment.NewLine
接下来,让你的datagridview单元格可以包装并自动调整行数,例如
DataGridView1.DefaultCellStyle.WrapMode = DataGridViewTriState.True
DataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
把它们放到桌面上以太网,演示如下所示:
公共 类 Form1
私有 Sub Form1_Load(sender 作为 对象,e 作为 EventArgs)句柄 MyBase .Load
Dim dt As 新 DataTable
dt.Columns.Add( 组合, GetType ( String ))
dt.Columns.Add( id, GetType (整数))
dt.Columns.Add( 名称, 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
结束 Sub
结束 类跨度>
如何使用..日期。多个数据??
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
I think, you mean Columns - not Rows ...
In this case it could be made like this :
my_DataGridView.Rows.Add ( myID , myName , myDate.tostring )
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:
vbCrLfor
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:
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
Yes.. already works for nvarch(MAX)
how to work with .. date . multiple datas??
这篇关于如何在datagridview单元格VB.NET上添加多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!