DOC

C#

By Antonio Reyes,2014-08-29 21:50
16 views 0
C#

    多文档编程 {((Form2)ActiveMdiChild).richTextBox1.SaveFile(sa退出 Application.Exit(); ve.FileName);

    保存文本; ActiveMdiChild.Text = save.FileName;}} } SaveFileDialog save = new SaveFileDialog(); 剪切;((Form2)ActiveMdiChild).richTextBox1.Cut();save.InitialDirectory = "D:\\"; 复制;Copy()

    if (save.ShowDialog() == DialogResult.OK) 粘贴;Paste();

    { string fname = save.FileName; 画一个矩形;Graphics g=e.Graphics;

     StreamWriter sw = File.AppendText(fname); Rectanglerect=newRectangle(50,30,100,100);

     sw.Write(this.richTextBox1.Text); LinearGradientBrush=new

     sw.Flush(); LinearGradientBrush(rect,Color.Red,Color.Yellow,Lin

     sw.Close();} earGradientMode.BackwardDiagonal);

     打开文本; g.FillRectangle(lBrush,rect);

     OpenFileDialog open = new OpenFileDialog(); 画一个弧; Graphics g=e.Graphics;

     open.Filter="Rich Text Format(*.rtf)|*.rtf|All Pen pn=new Pen(Color.Blue); Files(*.*)|*.*"; Rectanglerect=newRectangle(0,0,100,100);

     open.DefaultExt = "rtf"; g.DrawArc(pn,rect,12,84);

     if (open.ShowDialog() == DialogResult.OK) 输出文本; Font fnt=new Font("Verdana",16);

     { Form2 child = new Form2(); Graphics g=e.Graphics;

     child.Text == open.FileName; g.DrawString("GDI+World",fnt,new

     child.MdiParent=this; SolidBrush(Color.Red),50,50)

    child.richTextBox1.LoadFile(open.FileName); 连接数据库中的问题;

     child.Show();} 检索数据;AconnStr.Open();

    工具栏的处理方法: OleDbCommand Acmd = new

    if (toolStripMenuItem1.Checked) OleDbCommand("sleect top 5 * from User1 order by { toolStrip1.Dock = DockStyle.None; ID ;", AconStr);

     toolStrip1.Hide(); OleDbDataReader odr = null;

     toolStripMenuItem1.Checked = false;} if (odr != null)

     else{toolStripMenuItem1.Dock = DockStyle.Top; {

     toolStrip1.Show(); listBox1.Items.Add("ID号;用户名");

    toolStripMenuItem1.Checked=true;} while (odr.Read())

    层叠;this.LayoutMdi(MdiLayout.Cascade); {

    平铺;this.LayoutMdi(MdiLayout.TileHorizontal); string TotalInfo = "";

    排列; this.LayoutMdi(MdiLayout.ArrangeIcons); TotalInfo += odr["ID"].ToString() + "\t";

    工具栏上各个按钮的处理方法; TotalInfo += odr["用户名"].ToString() + "\n";

    else if (e.ClickedItem == 保存SToolStripButton) listBox1.Items.Add(TotalInfo + "\n");

    { }

    if (ActiveMdiChild != null) odr.Close();

    { }

     SaveFileDialog save = new SaveFileDialog(); 插入数据;OleDbCommand Icmd=new

     save.Filter="RichTextFormatFiles(*.rtf|*.rtf|All OleDbCommand(Insert into

    files(*.*)|*.*"; User1(ID,

     save.DefaultExt = "rtf"; 用户名)

     if (save.ShowDialog() == DialogResult.OK) values(1,NewPerson);,Acon

     nStr);

删除数据;OleDbCommand Dcmd=new Catch(Exception

    OleDbCommand(Delete from User1 ex){MessageBox.Show.(ex.Tostring());}}

    where ID =1;,AconnStr); 结束进程;If(listView1.SelectedItems.Count>0)

    AconnStr.Open(); {String

    Dcmd.ExecuteNonQuery(); str=listView1.SelectedEtems[0].SubItems[1].text; 修改数据;OleDbCommand Ucmd=new Int processID=Int32.Parse(str);

    OleDbCommand(Update User1 Set Process

    户名=test where ID=1;,AconnStr); selectedProcess=Process.GetProcessById(processID);

    AconnStr.Open(); seelectedProcess.Kill();}}

    Ucmd.ExecuteNonQuery(); 创建线程;class Program {static void Main(string

    创建进程;OpenFileDialog ofDlg=new []args){

    OpenFileDialog(); Thread newThread=new

    ofDlg.Filter=All Thread(new

    Executables(*.exe)|*.exe; ThreadStart(BackgroundWorker.DoWork));

    if(ofDlg.ShowDialog()==DialogResult.O newThread.Start(); }} K) class Work{Work(){}

    {Try{Process public static void DoWork() newProcess=Process.Start(ofDlg.FileName);} {Console.WriteLine("Static Methord"); }}

Report this document

For any questions or suggestions please email
cust-service@docsford.com