C# listbox读文本文档

更新时间:2023-07-18 21:42:55 阅读: 评论:0

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Web;
namespace WindowsApplication19
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object nder, EventArgs e)
{
StreamReader sr;
string s;
int len;
int num;
try
{
sr = File.OpenText("c:\\");
s = sr.ReadToEnd ();
len = s.Length;
num = len / 11 ;
label1.Text = len.ToString();
//for (int i = 0; i < num; i++)
//{
//    comboBox1.Items.Add(s.Substring (i*12,11));
/
/}
for (int i = 0; i < num; i++)
{
listBox1.Items.Add(s.Substring(i * 11, 11));
我的朋友300字}
sr.Clo();
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString ());
}
}
private void button1_Click(object nder, EventArgs e)
幼儿园小班科学教案{
int j = 0;
for (int i = listBox1.Items.Count - 1; i >= 0; i--)
{
if (listBox1.GetSelected(i))
{
listBox2.Items.Add(listBox1.Items[i]);
listBox1.Items.RemoveAt(i);
j = i;
}
}
for (; j >= 0; j--)
{
if (listBox1.Items.Count > j)
{
listBox1.SetSelected(j, true);
break;
}
}
}
private void button3_Click(object nder, EventArgs e)
{
int j = 0;
for (int i = listBox2.Items.Count - 1; i >= 0; i--)
{
if (listBox2.GetSelected(i))
{
listBox1.Items.Add(listBox2.Items[i]);
listBox2.Items.RemoveAt(i);
j = i;
}
}
for (; j >= 0; j--)
{
if (listBox2.Items.Count > j)
{
listBox2.SetSelected(j, true);
break;
}
}           
}
private void button2_Click(object nder, EventArgs e)
{     
listBox2.Items.AddRange(listBox1.Items );
listBox1.Items.Clear();
//int count;
//count = listBox1.Items.Count;
//for (int i = 0; i < count; i++)
//{
//    listBox2.Items.Add(listBox1.Items [i]);
//}
//listBox1.Items.C
lear();
硫磺皂可以洗脸吗
压字组词
}
private void listBox1_SelectedIndexChanged(object nder, EventArgs e)
{
//listBox2.Items.Add(listBox1.SelectedItem);
}
private void listBox1_MouDoubleClick(object nder, MouEventArgs e)
{
int j = 0;
for (int i = listBox1.Items.Count - 1; i >= 0; i--)
{
松茸的功效if (listBox1.GetSelected(i))
{
listBox2.Items.Add(listBox1.Items[i]);
listBox1.Items.RemoveAt(i);
j = i;
}
}
for (; j >= 0; j--)
{
if (listBox1.Items.Count > j)
{
listBox1.SetSelected(j, true);
break;
}
}
}
private void listBox2_MouDoubleClick(object nder, MouEventArgs e)
{
int j = 0;
for (int i = listBox2.Items.Count - 1; i >= 0; i--)
{
if (listBox2.GetSelected(i))
{
listBox1.Items.Add(listBox2.Items[i]);
listBox2.Items.RemoveAt(i);
j = i;
}
}
for (; j >= 0; j--)
{
if (listBox2.Items.Count > j)
{
listBox2.SetSelected(j, true);
break;
}
}         
}
private void button4_Click(object nder, EventArgs e)
{
listBox1.Items.AddRange(listBox2.Items);
listBox2.Items.Clear();
}
private void richTextBox1_TextChanged(object nder, EventArgs e)
{
StringBuilder sb = new StringBuilder();
sb = new StringBuilder(richTextBox1.Text.ToString(), 100);杭州市安全平台
int len;
len = richTextBox1.Text.Length;
int tiaoShu;
tiaoShu = len / 60 + 1;
for (int i = 0; i < tiaoShu; i++)
{
sb.Inrt(i * 66, ' '+ "第" + (i + 1) + "条:" + '\n');
}
richTextBox2.Text = sb.ToString();
label1.Text = len.ToString();
}
private void button5_Click(object nder, EventArgs e)
{
StreamWriter sw;
string time;
time = DateTime .Now .ToString ();
sw = File.AppendText("c:\\");
sw.WriteLine(richTextBox2.Text+"  "+time);
sw.Clo();
richTextBox2.Clear();
}
private void button6_Click(object nder, EventArgs e)
{
StreamReader sr;
string s;         
try
{
sr = File.OpenText("c:\\");
s = sr.ReadToEnd();
老年人头晕是什么原因知难行易辩论赛richTextBox3.Text = s.ToStri
ng ();             
sr.Clo();
}
catch (Exception ex)
{
MessageBox.Show("文件不存在");
}
}
private void button7_Click(object nder, EventArgs e)
{
StreamWriter sw;
sw = File.AppendText("c:\\");           
sw.Write(textBox1 .Text .Trim ());
sw.Clo();
//Form1.
textBox1.Clear();
listBox1.Items.Clear();
StreamReader sr;
string s;
int len;
int num;
try
{
sr = File.OpenText("c:\\");
s = sr.ReadToEnd();
len = s.Length;
num = len / 11;
label1.Text = len.ToString();
//for (int i = 0; i < num; i++)
//{
//    comboBox1.Items.Add(s.Substring (i*12,11));
//}
for (int i = 0; i < num; i++)
{
listBox1.Items.Add(s.Substring(i * 11, 11));
}
sr.Clo();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void button8_Click(object nder, EventArgs e)
{
listBox1.Items.AddRange(listBox2.Items);
listBox2.Items.Clear();
}
}
}

本文发布于:2023-07-18 21:42:55,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1086862.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:老年人   科学教案   硫磺
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图