VB.Net datagridview的打印或保存方法 [英] VB.Net datagridview print or saving method

查看:114
本文介绍了VB.Net datagridview的打印或保存方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要打开空白的datagridview并想输入一些数据,并且如果需要,需要保存在sql server数据库中,或者只想打印此数据而不保存,想要多次运行这种方法的datagridview.

want to open blank datagridview and want to entry some datas and if needed require save in sql server database, or only want to print this data without saving, want to run this datagridview like this method in several times. How it possible?

推荐答案

如果不保存就无法打印DatagridView数据.在关闭gridview时会提示您保存数据.


关闭时提示消息:

保留一个全局布尔值(将_bDocumentChanged设置为boolean),并在触发任何DataGridView事件时将布尔值设置为True,然后在Form_Closing()上检查该布尔值并抛出一个消息框.



You cannot print DatagridView data without saving.Better prompt a message to save the data while closing gridview.


Prompting Message while Closing:

Keep a global boolean (Dim _bDocumentChanged as boolean) and when any DataGridView events are fired set your boolean to True and then on the Form_Closing() check that boolean and throw a message box.

OR

Private Sub YourDataGridViewForm_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
    If MessageBox.Show(Me, "Do you want to save your changes?", "Unsaved Changes!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.Yes Then
        SaveChanges()
    End If
End Sub

Private Sub SaveChanges()
    MessageBox.Show("Changes saved...")
End Sub


这篇关于VB.Net datagridview的打印或保存方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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