编辑Windows窗体的网格视图数据 [英] edit grid view data for windows form

查看:74
本文介绍了编辑Windows窗体的网格视图数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Windows窗体.
1 -----------------------------
我正在使用网格视图.
当我选择网格视图行时,我想要那个.
所选行数据将在文本框中显示.
当我单击编辑"按钮时
它将保存在数据库中.

2 -----------------------
选择行时我想要
被选中的行应删除.


请帮帮我
编写这段代码

谢谢和问候
subiya

i m working on windows form.
1-----------------------------
i m using a grid view.
i want that when i select the grid view row.
the selected row data will be dispay in the text boxes.
and when i click the button of edit
it will save in data base.

2-----------------------
i want when i select the row
the slelected row should be deleted.


please help me out
to write this code

thanks and regard
subiya

推荐答案



``我认为这段代码将对您有所帮助
''将数据输入到datagrid视图
''在datagridview中的RowHeaderMouseDoubleClick事件中...

Hi,

''I think this code will help u
''enter data to datagrid view
''in datagridview RowHeaderMouseDoubleClick event...

Dim v_cellno As Integer
       Dim m_GrdRw() As String

       If DataGridView1.RowCount = 0 Then Exit Sub

       ReDim m_GrdRw(DataGridView1.ColumnCount)

       For v_cellno = 0 To DataGridView1.ColumnCount - 1
           m_GrdRw(v_cellno) = DataGridView1.Item(v_cellno, DataGridView1.SelectedCells(v_cellno).RowIndex).Value.ToString
       Next v_cellno
       TextBox1.Text = m_GrdRw(0)
       TextBox2.Text = m_GrdRw(1)
       TextBox3.Text = m_GrdRw(2)
       TextBox4.Text = m_GrdRw(3)
       TextBox5.Text = m_GrdRw(4)


       Dim rowToDelete As Int32 = Me.DataGridView1.Rows.GetFirstRow( _
       DataGridViewElementStates.Selected)
       If rowToDelete > -1 Then
           Me.DataGridView1.Rows.RemoveAt(rowToDelete)
       End If


' Here u can import the data of textboxes to your database


1.您需要使用此示例中显示的数据网格的CurrentRow

1. You need to use the datagrid''s CurrentRow as shown in this sample

Textbox1.text = datagridview1.currentrow.cells(i).value
'where i is the poistion in the row that you want get out



关于2,到目前为止,您还没有提供有关如何处理数据的任何详细信息?您正在使用数据层吗? tableadapters?



in regards to 2 you haven''t given any details on how your handling your data so far? are you using a datalayer? tableadapters?


使用分页在DataGridView中添加,编辑和删除 [^ ]
检查一下,自己尝试尝试一下,如果卡在某个地方,然后再找回.
Add, Edit, and Delete in DataGridView with Paging[^]
Check this out, try something on your own, and then get back if you are stuck somewhere.


这篇关于编辑Windows窗体的网格视图数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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