如何在“我的电脑”中以Txt / Word格式保存我的Vb.Net表单的所有内容 [英] How Can I Save All The Contents Of My Vb.Net Form In Txt/Word Format In My Computer

查看:72
本文介绍了如何在“我的电脑”中以Txt / Word格式保存我的Vb.Net表单的所有内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我创建了我的表单,它是文本框,组合框,标签等的组合。现在,我有一个打印预览选项/打印选项,但我需要有一个保存文件选项。我已经使用了保存文件对话框并试图保存表单,但当我回去检查txt文件时。它显示该文件为空。所以,任何人都可以帮我保存选项,使表格的所有内容完全复制并保存在我想要的位置。请帮帮我

So, i have created my form which is a combination of textbox, combobox, labels etc. Now, i have a print preview option/ print option but i need to have a save file option. I have used the save file dialog and tried to save the form but when i go back and check the txt file. It shows that the file is empty. So, can anyone help me with the save option such that all the contents of the form is totally copied and saved in my desired location. Please help me out

推荐答案

您需要获取表单中所有控件的集合并遍历所有控件,检查它是什么类型的控件并获取Text或SelectedItems。这很难,之后你需要很好地格式化文本。



最好有一个代表文档的类并在每次表单时更新它被更改或保存。然后将Document写入文件。
Either you need to get the collection of all Controls in the Form and iterate through all of them, check what type of Control it is and get the Text or SelectedItems. This would be difficult and you'd need to format the text nicely afterwards.

It would be better to have a Class representing a Document and update it every time the Form is altered or Saved. Then write the Document to a file.


这篇关于如何在“我的电脑”中以Txt / Word格式保存我的Vb.Net表单的所有内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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