如何在datagridview单元格VB.NET上添加多行 [英] How to add multi rows on a datagridview cell VB.NET

查看:445
本文介绍了如何在datagridview单元格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.AutoSizeRowsMo​​de = DataGridViewAutoSizeRowsMo​​de.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.AutoSizeRowsMo​​de = DataGridViewAutoSizeRowsMo​​de.AllCells
DataGridView1.DataSource = dt
结束 Sub
结束


是..已经适用于nvarch(MAX)



如何使用..日期。多个数据??


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:

vbCrLf

or

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆