需要帮助DataGridView Update按钮 [英] Need help with DataGridView Update button

查看:126
本文介绍了需要帮助DataGridView Update按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在VS上用VB编程。  我正在为DataGridView添加更新按钮功能。我添加了一个DataGridViewButtonColumn,它应该作为程序的更新按钮。该程序本身是一个简单的事件提醒,但我想
添加一个更新功能,它将更新你点击按钮的行。当您单击更新按钮时,它会弹出一个窗口,允许您更改日期和事件描述,但我似乎无法弄清楚为什么它不起作用。这是按钮的代码I

So I am programming in VB on VS.  I am adding an update button feature to my DataGridView. I added a DataGridViewButtonColumn that is supposed to work as an update button for the program. The program itself is a simple event reminder, but I want to add an update feature that will update the row you click the button on. When you click the update button it pops up a window that allows you to change the date and the event description but I cant seem to figure out why its not working. This is the code I have for the button

        MainForm1.DataGridView1.SelectedRows.ToString(){date2.Text,TextBox3.Text})

        Me.Close()

        MainForm1.DataGridView1.SelectedRows.ToString() {date2.Text, TextBox3.Text})
        Me.Close()

date2表示将事件更改为的日期,TextBox3表示事件描述更改。 VS表示"预期结束声明"我做错了什么或者我可以改变什么?我甚至走在正确的道路上吗?顺便说一下,我只是
从Visual Basic开始,所以我不是任何方式的专家,如果可能的话我只想要一些输入和指导。任何回应都是很好的回应。感谢您的时间。

date2 represents the date you change the event to and TextBox3 represents the event description changes. VS says that a "End of statement is expected" what did I do wrong or what could I change? Am I even on the right path? By the way I am just starting out with visual basic so I am not an expert in any way I just want some input and guidance if possible. Any response is a good response. Thank you for your time.

推荐答案

试试这个:

Dim row = MainForm1.DataGridView1.CurrentRow
row.Cells(0).Value = date2.Text
row.Cells(1).Value = TextBox3.Text
Me.Close()

其中0和1是要更改的列的索引。

顺便说一句,请查看这个特殊的VB论坛:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vbgeneral


这篇关于需要帮助DataGridView Update按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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