在vb中读取datagridview列中的每个单元格 [英] Read each cell in column of datagridview in vb

查看:77
本文介绍了在vb中读取datagridview列中的每个单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有新对象..我想通过使用行添加Datagridview中的所有单元格表格..并且Anew Label中的每个单元格..以及其他之前的每个标签..这都是谢谢。

这个代码可以帮助你帮助我。

For Each row As DataGridViewRow In DataGridView1.Rows
        Dim new_label As New Label()
        new_label.Parent = Me
        new_label.Location = New Point(100, 20)
        new_label.DataBindings.Add("Text", DataSet1, "TableA.name")
    Next




谢谢


Thank you

推荐答案

对于标签位置,您需要有一个变量,可以为下一个标签的顶部位置递增,并设置间隔为添加到变量然后设置顶部值。对于DataBinding,第二个参数是DataSet
中的表,即DataSet1.Tables然后通过DataSet中的TableName或索引引用您的表,最后一个参数是表中的字段名。

For the label position you will need to have a variable that can be incremented for the Top position of the next label with a set interval to add to the variable then set the top value. For DataBinding the second parameter would be the table in the DataSet i.e. DataSet1.Tables then reference your table by TableName or index in the DataSet, the last parameter is the field name in the table.

因此,尝试一下,如果您发出问题,请向我们展示您的代码并准确说明问题所在。

So with that given try it out and if you issues come back, show us your code and indicate exactly what is the problem.

定位标签的概念证明

Dim iTop As Int32 = 20For x As Int32 = 0 To 5    Dim new_label As New Label()    new_label.Parent = Me    new_label.Location = New Point(100, iTop)    new_label.Text = "Test " & x.ToString    iTop += 25Next





这篇关于在vb中读取datagridview列中的每个单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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