文本框和文本文件 [英] textbox and textfile

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

问题描述

如何使您的程序读取文本文件?

我知道如何将文本文件作为资源导入.但是我不知道如何让程序将文本文件中的TEXT
显示为(只读)textbox1....

让我举一个例子说明我的意思

假设您想创建一个讲述三个小熊的故事的程序

现在我们在form1上有2个按钮和一个控件文本框.

button1移至下一行故事中的文本
button2向后移动到文本的前一行
textbox1从故事中的第一行文本开始显示故事文本

这就是我正在尝试做的事情



How do you get your program to read a text file?

I know how to import a textfile as a resource. But I dont know how to get the program to show the TEXT
in the textfile to a (readonly)textbox1...

let me give ya an example of what i mean

lets say you wanted to make a program that told the story of the three little bears

alright now we got 2 buttons and a textbox for controls on our form1.

button1 moves to the next line of text in the story
button2 moves backwards to the previous line of text
textbox1 is displaying the story text, from the first line of text in the story

this is what im trying to do



推荐答案

从流读取器读取是仅转发对象.你不能回去.我想不到的是,能够前进和后退的最简单方法是一次将一行故事读入一个收藏集中.集合中的每个项目都可能是故事中的一行,如果您知道那是故事的话,这将使您可以前后移动,甚至转到某个编号的行.让我知道您是否需要使用集合的更多信息.
Reading from a stream reader is a forward only object. You cannot go back. Off the top of my head I am thinking that the easiest way for you to be able to move forward and backward is to read your story one line at a time into a collection. Each item in the collection could be a line from the story, this would allow you to go back and forward and even go to a certain numbered line if you knew what it was. Let me know if you need more information on using a collection.


这篇关于文本框和文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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