| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 655 人关注过本帖
标题:控件textBox4中不显示数据
取消只看楼主 加入收藏
lsyanwan
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2007-1-22
收藏
 问题点数:0 回复次数:1 
控件textBox4中不显示数据
Form1界面:
 public partial class Form1 : Form
    {
        string FName;            
        public Form1()
        {
            InitializeComponent();                     
        }
 private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                FName = openFileDialog1.FileName;               
                Form2 newchild = new Form2(FName);
                newchild.Show();               
            }
         }
}
Form2界面:
public partial class Form2 : Form
    {

        Form1 tempForm = new Form1();
        private string fName;
      
        public Form2( string fname)
        {
            InitializeComponent();
            
            this.fName = fname;
        }        
        public void button1_Click(object sender, EventArgs e)
        {
            if (this.radioButton1.Checked)
            {
               File fileOpen = new File(fName);               
               tempForm.textBox4.Text = fileOpen.ReadFile();
               tempForm.textBox4.AppendText("");               
              this.Close();                 
            }
        }
        public class File
        {
            string fileName;
            public File(string fileName)
            {
                this.fileName = fileName;
            }
            public string ReadFile()
            {
                try
                {
                    StreamReader sr = new StreamReader(fileName, Encoding.Default);
                    string result = sr.ReadToEnd();
                    sr.ReadLine();
                    sr.Close();
                    return result;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                    return null;
                }           
            }
        }      
 程序执行后,Form1界面的控件textBox4不显示数据.为什么?
搜索更多相关主题的帖子: 控件 数据 
2007-12-21 15:44
lsyanwan
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2007-1-22
收藏
得分:0 
回复 2# 的帖子
成功了,谢谢!

2007-12-21 16:11
快速回复:控件textBox4中不显示数据
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016641 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved