日本好好热aⅴ|国产99视频精品免费观看|日本成人aV在线|久热香蕉国产在线

  • <cite id="ikgdy"><table id="ikgdy"></table></cite>
    1. 西西軟件園多重安全檢測下載網(wǎng)站、值得信賴的軟件下載站!
      軟件
      軟件
      文章
      搜索

      首頁編程開發(fā)C#.NET → C# - winform編程問題 使用TextBox button ComboBox三個控件

      C# - winform編程問題 使用TextBox button ComboBox三個控件

      相關(guān)軟件相關(guān)文章發(fā)表評論 來源:本站整理時間:2010/7/25 12:45:13字體大。A-A+

      作者:佚名點(diǎn)擊:452次評論:0次標(biāo)簽: C#

      API精靈FOR c#v2.35 最新版
      • 類型:編程輔助大。324KB語言:中文 評分:7.5
      • 標(biāo)簽:
      立即下載

      一共有TextBox button ComboBox三個控件 、在Textbox里輸入內(nèi)容、點(diǎn)添加 、就把內(nèi)容添加到了ComboBox中 、 內(nèi)容需要寫入到XML或者記事本、下次重啟軟件的時候添加的內(nèi)容才會存在 、請問我該如何把我輸入的內(nèi)容添加到XML或者記事本中?

      隨便寫了個代碼,通過記錄文本實(shí)現(xiàn)的。

      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Data;
      using System.Drawing;
      using System.Linq;
      using System.Text;
      using System.Windows.Forms;
      using System.IO;

      namespace WindowsFormsApplication4
      {
      public partial class Form1 : Form
      {
      public Form1()
      {
      InitializeComponent();
      }

      private void Form1_Load(object sender, EventArgs e)
      {
      FileInfo DataFile;
      DataFile = new FileInfo(@"c:\2.txt");
      if (DataFile.Exists)
      {
      StreamReader sr = new StreamReader(@"c:\2.txt", Encoding.GetEncoding("GB2312"), true);
      string line;
      while ((line = sr.ReadLine()) != null)
      {
      comboBox1.Items.Add(line);

      }
      sr.Close();
      }
      else
      {
      DataFile.Create();

      }

      }

      private void button1_Click(object sender, EventArgs e)
      {
      if (textBox1.Text != "")
      {
      GC.Collect();
      StreamWriter writeline = new StreamWriter(@"c:\2.txt", true, Encoding.GetEncoding("GB2312"));
      writeline.Write(textBox1.Text + "\r\n");
      writeline.Flush();
      writeline.Close();
      comboBox1.Items.Add(textBox1.Text);
      textBox1.Text = "";
      }
      else
      {
      MessageBox.Show("請輸入內(nèi)容");
      }
      }

       

      }
      }

        相關(guān)評論

        閱讀本文后您有什么感想? 已有人給出評價!

        • 8 喜歡喜歡
        • 3 頂
        • 1 難過難過
        • 5 囧
        • 3 圍觀圍觀
        • 2 無聊無聊

        熱門評論

        最新評論

        發(fā)表評論 查看所有評論(0)

        昵稱:
        表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
        字?jǐn)?shù): 0/500 (您的評論需要經(jīng)過審核才能顯示)