试着写&将结果附加到文件

时间:2012-03-12 19:49:24

标签: c# windows-forms-designer windows-applications

下面我的(相当)简单应用程序的图像,是它的代码。我需要知道如何将comboBox1(位置),comboBox2(药物),textBox1(数量)和textBox2(日期)导出到CSV或Excel类型文件,以运行报告。我和C#已经两个星期了,可以真正使用这个帮助,因为我已经在这个部分工作,特别是在工作上大约一个星期了!

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;

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

                private void button1_Click(object sender, EventArgs e)
                {

                }

                private void button2_Click(object sender, EventArgs e)
                {

                }

                private void button3_Click(object sender, EventArgs e)
                {
                    Application.Exit();
                }

                private void exitToolStripMenuItem_Click(object sender, EventArgs e)
                {
                    Application.Exit();
                }

                private void toolStripMenuItem1_Click(object sender, EventArgs e)
                {
                }

                private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
                {
                }

                private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
                {
                    dateTimePicker1.CustomFormat = "dd/MM/yyyy";
                    dateTimePicker1.MinDate = DateTime.Today;
                    dateTimePicker1.MaxDate = DateTime.Today;
                }

                private void label4_Click(object sender, EventArgs e)
                {
                }

                private void textBox2_TextChanged(object sender, EventArgs e)
                {
                    textBox2.Text = DateTime.Now.ToString();
                }


        }
}][1]

1 个答案:

答案 0 :(得分:0)

  • 文本框具有.Text属性
  • 组合框具有.SelectedItem属性

你可以写这样的文本文件......

http://msdn.microsoft.com/en-us/library/8bh11f1k.aspx