⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exportform.cs

📁 C#自定义查询控件
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace CommonComponent.CommonIE
{
	/// <summary>
	/// Summary description for ExportFrm.
	/// </summary>
	public class ExportForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.RadioButton radioButton1;
		private System.Windows.Forms.RadioButton radioButton2;
		private System.Windows.Forms.RadioButton radioButton3;
		private System.Windows.Forms.RadioButton radioButton4;
		private System.Windows.Forms.RadioButton radioButton5;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.RadioButton radioButton6;
		private System.Windows.Forms.RadioButton radioButton7;
		private System.Windows.Forms.RadioButton radioButton8;
		private System.Windows.Forms.RadioButton radioButton9;
		private System.Windows.Forms.RadioButton radioButton10;
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.GroupBox groupBox2;
		private System.Windows.Forms.GroupBox groupBox3;
		private System.Windows.Forms.GroupBox groupBox4;
		private System.Windows.Forms.GroupBox groupBox5;
		private System.Windows.Forms.RadioButton radioButton11;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public ExportForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.radioButton1 = new System.Windows.Forms.RadioButton();
			this.radioButton2 = new System.Windows.Forms.RadioButton();
			this.radioButton3 = new System.Windows.Forms.RadioButton();
			this.radioButton4 = new System.Windows.Forms.RadioButton();
			this.radioButton5 = new System.Windows.Forms.RadioButton();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.radioButton10 = new System.Windows.Forms.RadioButton();
			this.radioButton9 = new System.Windows.Forms.RadioButton();
			this.radioButton8 = new System.Windows.Forms.RadioButton();
			this.radioButton7 = new System.Windows.Forms.RadioButton();
			this.radioButton6 = new System.Windows.Forms.RadioButton();
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.groupBox2 = new System.Windows.Forms.GroupBox();
			this.groupBox3 = new System.Windows.Forms.GroupBox();
			this.groupBox4 = new System.Windows.Forms.GroupBox();
			this.groupBox5 = new System.Windows.Forms.GroupBox();
			this.radioButton11 = new System.Windows.Forms.RadioButton();
			this.groupBox1.SuspendLayout();
			this.SuspendLayout();
			// 
			// radioButton1
			// 
			this.radioButton1.Checked = true;
			this.radioButton1.Location = new System.Drawing.Point(15, 15);
			this.radioButton1.Name = "radioButton1";
			this.radioButton1.Size = new System.Drawing.Size(200, 20);
			this.radioButton1.TabIndex = 0;
			this.radioButton1.TabStop = true;
			this.radioButton1.Text = "输出到Microsoft Excel(*.xls)";
			// 
			// radioButton2
			// 
			this.radioButton2.Location = new System.Drawing.Point(15, 53);
			this.radioButton2.Name = "radioButton2";
			this.radioButton2.Size = new System.Drawing.Size(200, 20);
			this.radioButton2.TabIndex = 1;
			this.radioButton2.Text = "输出到Microsoft dBase(*.dbf)";
			// 
			// radioButton3
			// 
			this.radioButton3.Location = new System.Drawing.Point(15, 91);
			this.radioButton3.Name = "radioButton3";
			this.radioButton3.Size = new System.Drawing.Size(200, 20);
			this.radioButton3.TabIndex = 2;
			this.radioButton3.Text = "输出到Html(*.htm)";
			// 
			// radioButton4
			// 
			this.radioButton4.Location = new System.Drawing.Point(15, 129);
			this.radioButton4.Name = "radioButton4";
			this.radioButton4.Size = new System.Drawing.Size(200, 20);
			this.radioButton4.TabIndex = 3;
			this.radioButton4.Text = "输出到CSV(*.csv)";
			// 
			// radioButton5
			// 
			this.radioButton5.Location = new System.Drawing.Point(15, 167);
			this.radioButton5.Name = "radioButton5";
			this.radioButton5.Size = new System.Drawing.Size(200, 20);
			this.radioButton5.TabIndex = 4;
			this.radioButton5.Text = "输出到文本文件(*.txt)";
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.radioButton11);
			this.groupBox1.Controls.Add(this.textBox1);
			this.groupBox1.Controls.Add(this.radioButton10);
			this.groupBox1.Controls.Add(this.radioButton9);
			this.groupBox1.Controls.Add(this.radioButton8);
			this.groupBox1.Controls.Add(this.radioButton7);
			this.groupBox1.Controls.Add(this.radioButton6);
			this.groupBox1.Location = new System.Drawing.Point(5, 190);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(274, 105);
			this.groupBox1.TabIndex = 5;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "分隔符号";
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(188, 50);
			this.textBox1.MaxLength = 1;
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(59, 21);
			this.textBox1.TabIndex = 5;
			this.textBox1.Text = "";
			// 
			// radioButton10
			// 
			this.radioButton10.Location = new System.Drawing.Point(102, 50);
			this.radioButton10.Name = "radioButton10";
			this.radioButton10.Size = new System.Drawing.Size(78, 20);
			this.radioButton10.TabIndex = 4;
			this.radioButton10.Text = "其它(&O):";
			// 
			// radioButton9
			// 
			this.radioButton9.Location = new System.Drawing.Point(16, 51);
			this.radioButton9.Name = "radioButton9";
			this.radioButton9.Size = new System.Drawing.Size(78, 20);
			this.radioButton9.TabIndex = 3;
			this.radioButton9.Text = "空格(&S)";
			// 
			// radioButton8
			// 
			this.radioButton8.Location = new System.Drawing.Point(188, 22);
			this.radioButton8.Name = "radioButton8";
			this.radioButton8.Size = new System.Drawing.Size(78, 20);
			this.radioButton8.TabIndex = 2;
			this.radioButton8.Text = "逗号(&C)";
			// 
			// radioButton7
			// 
			this.radioButton7.Location = new System.Drawing.Point(102, 22);
			this.radioButton7.Name = "radioButton7";
			this.radioButton7.Size = new System.Drawing.Size(78, 20);
			this.radioButton7.TabIndex = 1;
			this.radioButton7.Text = "分号(&M)";
			// 
			// radioButton6
			// 
			this.radioButton6.Checked = true;
			this.radioButton6.Location = new System.Drawing.Point(16, 22);
			this.radioButton6.Name = "radioButton6";
			this.radioButton6.Size = new System.Drawing.Size(78, 20);
			this.radioButton6.TabIndex = 0;
			this.radioButton6.TabStop = true;
			this.radioButton6.Text = "Tab键(&T)";
			// 
			// button1
			// 
			this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
			this.button1.Location = new System.Drawing.Point(104, 301);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(75, 25);
			this.button1.TabIndex = 6;
			this.button1.Text = "确定(&O)";
			// 
			// button2
			// 
			this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.button2.Location = new System.Drawing.Point(187, 301);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(75, 25);
			this.button2.TabIndex = 7;
			this.button2.Text = "取消(&C)";
			// 
			// groupBox2
			// 
			this.groupBox2.Location = new System.Drawing.Point(17, 40);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(251, 3);
			this.groupBox2.TabIndex = 8;
			this.groupBox2.TabStop = false;
			// 
			// groupBox3
			// 
			this.groupBox3.Location = new System.Drawing.Point(17, 78);
			this.groupBox3.Name = "groupBox3";
			this.groupBox3.Size = new System.Drawing.Size(251, 3);
			this.groupBox3.TabIndex = 9;
			this.groupBox3.TabStop = false;
			// 
			// groupBox4
			// 
			this.groupBox4.Location = new System.Drawing.Point(17, 116);
			this.groupBox4.Name = "groupBox4";
			this.groupBox4.Size = new System.Drawing.Size(251, 3);
			this.groupBox4.TabIndex = 10;
			this.groupBox4.TabStop = false;
			// 
			// groupBox5
			// 
			this.groupBox5.Location = new System.Drawing.Point(17, 154);
			this.groupBox5.Name = "groupBox5";
			this.groupBox5.Size = new System.Drawing.Size(251, 3);
			this.groupBox5.TabIndex = 11;
			this.groupBox5.TabStop = false;
			// 
			// radioButton11
			// 
			this.radioButton11.Location = new System.Drawing.Point(16, 77);
			this.radioButton11.Name = "radioButton11";
			this.radioButton11.Size = new System.Drawing.Size(78, 20);
			this.radioButton11.TabIndex = 6;
			this.radioButton11.Text = "等宽(&W)";
			// 
			// ExportForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(284, 338);
			this.Controls.Add(this.groupBox5);
			this.Controls.Add(this.groupBox4);
			this.Controls.Add(this.groupBox3);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.radioButton5);
			this.Controls.Add(this.radioButton4);
			this.Controls.Add(this.radioButton3);
			this.Controls.Add(this.radioButton2);
			this.Controls.Add(this.radioButton1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.Name = "ExportForm";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "导出数据";
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion



		public static bool SelectType(ref string eType,ref string separator)
		{
			using (ExportForm frmexp =new ExportForm())
			{
				if (frmexp.ShowDialog() == DialogResult.OK)
				{
					if(frmexp.radioButton1.Checked)
					{
						eType = ".xls";
						return true;
					}
					else if(frmexp.radioButton2.Checked )
					{
						eType = ".dbf";
						return true;
					}
					else if(frmexp.radioButton3.Checked)
					{
						eType = ".htm";
						return true;
					}
					else if(frmexp.radioButton4.Checked)
					{
						eType = ".csv";
						return true;
					}
					else
					{
						eType = ".txt";
						if(frmexp.radioButton6.Checked)
							separator = "\t";
						else if(frmexp.radioButton7.Checked)
							separator = ";";
						else if(frmexp.radioButton8.Checked)
							separator = ",";
						else if(frmexp.radioButton9.Checked)
							separator = " ";
						else if(frmexp.radioButton10.Checked)
						{
							separator = frmexp.textBox1.Text;
							if (separator == "")
								separator ="\t";
						}
						else if(frmexp.radioButton11.Checked)
						{
							eType = ".sdf";
						};
						return true;
					}
				}
				else
                    return false;
			}
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -