如何将所有列表框值发送到网格视图 [英] how to send all listbox values to the grid view

查看:69
本文介绍了如何将所有列表框值发送到网格视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将列表框的所有值传递给gridview ..执行此操作的步骤或步骤是什么....

I want to transfer the all values of list box to the gridview..what are the steps or procedure for doing this....

推荐答案





1)用列创建数据表。

2)将所有列表框值复制到数据表中。

3)将该数据表绑定到网格视图中。



我在按钮点击事件中添加了代码



Hi,

1) Create a data table with a column.
2) Copy all the list box values to data table.
3) Bind that data table into the Grid View.

I have added code in button click event

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       Dim dt As New DataTable
       dt.Columns.Add("Values")

       Dim iPos As Integer
       For iPos = 0 To ListBox1.Items.Count - 1
           Dim dr As DataRow = dt.NewRow
           dr(0) = ListBox1.Items(iPos).ToString()
           dt.Rows.Add(dr)
       Next
       DataGridView1.DataSource = dt
   End Sub





希望这会有所帮助。



最好的问候

Muthuraja



Hope this helps.

Best Regards
Muthuraja


这篇关于如何将所有列表框值发送到网格视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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