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 ...
随机推荐
- MySQL数据库中文乱码问题
mysql> select * from books; +-----+---------------------------------+---------+-------------+---- ...
- quick: setup_mac.sh分析
//quick: setup_mac.sh分析 //quick: setup_mac.sh分析#!/bin/bash //获取并打印根目录QUICK_V3_ROOTDIR="$( cd &q ...
- Centos7 配置静态IP并使用xshell远程连接
静态IP配置 1.定位到 /etc/sysconfig/network-scripts文件夹,打开文件夹下面的ifcfg-enp3s0文件 2.修改BOOTPROTO=static ONBOOT=y ...
- 关于org.apache.lucene.queryParser.ParseException: Encountered "" 解决方法
现象: org.apache.lucene.queryParser.ParseException: Encountered "<EOF>" at line 1, col ...
- [技术博客] 数据库1+N查询问题
目录 问题简述 问题解决 group的方法简化查询 改正后的代码 作者:庄廓然 问题简述 本次开发过程中我们用到了rails的orm框架,使用orm框架可以很方便地进行对象的关联和查询,例如查询一个用 ...
- [Beta]Scrum Meeting#10
github 本次会议项目由PM召开,时间为5月15日晚上10点30分 时长15分钟 任务表格 人员 昨日工作 下一步工作 木鬼 撰写博客整理文档 撰写博客整理文档 swoip 为适应新功能调整布局前 ...
- Java基础 awt Frame 窗体在屏幕的中间显示
JDK :OpenJDK-11 OS :CentOS 7.6.1810 IDE :Eclipse 2019‑03 typesetting :Markdown code ...
- js---省略花括号{}的几种表达式
在进行js的书写中,对于常见的if,for,while是可以简写,省略花括号{}的: var a = 10,b = 20; /** * if 简写 */ if(a > b) console.lo ...
- win10更改pip源
摘自:https://blog.csdn.net/qq_31443999/article/details/88750833 win10安装TensorFlow卡崩更改为国内清华大学镜像源,即可. 具体 ...
- MongoDB开发深入之二:索引
索引分类: 默认索引 单一索引 复合索引 多键索引(数组索引) 全文检索索引 2dsphere 索引 2D索引 ...... 索引属性: 到期TTL 唯一索引 部分索引 稀疏索引 索引通常能够极大的提 ...