dataGridView读写文本
constant con = new constant();
private void loadlistbox2()
        {
            dataGridView1.ColumnCount = 1;
            string z;
            if (File.Exists(".//allitems.txt"))
            {
                FileStream fs = new FileStream(".//allitems.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read);
StreamReader sr = new StreamReader(fs, System.Text.Encoding.GetEncoding("utf-8"));
                try
                {
                    while (true)
                    {
                        z = sr.ReadLine();
                        if (z == null) break;
                        dataGridView1.Rows.Add(z);
                    }
                }
                finally
                {
                    sr.Close();
                    fs.Dispose();
                    fs.Close();
                }
            }
        }
        string st = "";
private void savetestitem()
        {
           // dataGridView1.ColumnCount = 1;
            if (File.Exists(".//allitems.txt"))
            {
                FileStream fs = new FileStream(".//allitems.txt", System.IO.FileMode.Open, System.IO.FileAccess.Write);
StreamWriter sr = new StreamWriter(fs, System.Text.Encoding.GetEncoding("utf-8"));
                try
                {
                    for (int i = 0; i < 22; i++)
                    {
                        for (int j = 0; j < 1; j++)
                        {
                            st = st + dataGridView1.Rows[i].Cells[j].Value;
                        }
                        sr.WriteLine(st);
                        st = "";
//for (int i = 0; i < dataGridView1.Rows.Count; i++)
                        //{
                        //        sr.WriteLine(dataGridView1.Rows[i].Cells);
                        //    }
                       }
}              
                finally
                {
                    sr.Close();
                    fs.Dispose();
                    fs.Close();
                }
            }
        }
dataGridView读写文本的更多相关文章
- 背水一战 Windows 10 (89) - 文件系统: 读写文本数据, 读写二进制数据, 读写流数据
		[源码下载] 背水一战 Windows 10 (89) - 文件系统: 读写文本数据, 读写二进制数据, 读写流数据 作者:webabcd 介绍背水一战 Windows 10 之 文件系统 读写文本数 ... 
- iOS 9应用开发教程之多行读写文本ios9文本视图
		iOS 9应用开发教程之多行读写文本ios9文本视图 多行读写文本——ios9文本视图 文本视图也是输入控件,与文本框不同的是,文本视图可以让用户输入多行,如图2.23所示.在此图中字符串“说点什么吧 ... 
- python_py2和py3读写文本区别
		python2和python3的区别? python 2 str 对应 python3 bytes python 2 uincode 对应 ... 
- 零基础学python-3.7 还有一个程序 python读写文本
		今天我们引入另外一个程序,文件的读写 我们先把简单的程序代码贴上.然后通过我们多次的改进.希望最后可以变成一个简单的文本编辑器 以下是我们最简单的代码: 'crudfile--读写文件' def re ... 
- Python之读写文本数据
		知识点不多 一:普通操作 # rt 模式的 open() 函数读取文本文件 # wt 模式的 open() 函数清除覆盖掉原文件,write新文件 # at 模式的 open() 函数添加write ... 
- Python-py2和py3读写文本区别
		python2和python3的区别? python 2 str 对应 python3 bytes python 2 uincode 对应 ... 
- delphi 读写文本
		将字符串写入txt文档,读取txt文档中的内容. //一次写字符串到文本文件,每次都会将原来的内容替换掉. procedure FilePutContents(f,s:String); // f为文件 ... 
- C#读写文本和连接数据库
		using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ... 
- 读写文本(.txt)文件 .NET
		http://www.cnblogs.com/jx270/archive/2013/04/14/3020456.html (一) 读取文件 如果你要读取的文件内容不是很多,可以使用 File.Read ... 
随机推荐
- 数据库的范式(1NF、2NF、3NF、BCNF)转载
			文章属于转载:https://www.cnblogs.com/hi-bazinga/archive/2012/06/05/2536806.html 第一范式:关系模式中,每个属性不可再分.属性原子性第 ... 
- JS 将数字字符串数组转为 数字数组 (互换)
			var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]; arr.map(String); //结果: ['1', '2', '3', '4', '5', '6', '7', '8 ... 
- 拦截RestTemplate的请求
			RestTemplate一般用于方法内部请求调用,请求报错时难以调试,所以可以为RestTemplate加拦截器进行调试,具体操作如下: 拦截器LoggingClientHttpRequestInte ... 
- yarn一些最佳配置
			合理设置队列名 mapreduce.job.queuename设置队列名map读取时进行小文件整合 mapreduce.input.fileinputformat.split.minsize mapr ... 
- HttpClient 连接泄漏问题
			AbstractConnPool.java 提交记录 https://github.com/apache/httpcomponents-core/commits/4.4.x/httpcore/src/ ... 
- 【转】干货篇:手机绕过BL锁9008模式强刷
			<ignore_js_op> 高通QPST线刷其实就是利用高通芯片自带的9008端口,将手机系统内的所有分区的镜像文件,直接刷写手机.这个刷机方式比REC卡刷和fastboot线刷,更底层 ... 
- Cesium原理篇:GroundPrimitive【转】
			今天来看看GroundPrimitive,选择GroundPrimitive有三个目的:1 了解GroundPrimitive和Primitive的区别和关系 2 createGeometry的特殊处 ... 
- HTML5中的Web Worker技术
			为了让后台程序更好的执行,在HTML5中设计了Web Worker技术.Web Worker的产生主要是考虑到在HTML4中JavaScript Web程序都是以单线程的方式执行的,一旦前面的脚本花费 ... 
- gcc 编译两个so其中soA依赖soB
			有两个so,其中soB中调用soA: 那么我们打包soB的时候连接soA: 在打包test程序的时候连接soB,此时soB会自动查找依赖的soA: 如下测试 在编译之前指定环境变量:export LD ... 
- 平时没有怎么用Excel做 加减乘除 计算,猛地发现,其实Excel 是一个很好的简单计算器
			平时没有怎么用Excel做 加减乘除 计算,猛地发现,其实Excel 是一个很好的简单计算器 
