Click The Button Of The Form Made In C# To Open The Desired File

  • Uploaded by: Syed Arbab Ahmed
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Click The Button Of The Form Made In C# To Open The Desired File as PDF for free.

More details

  • Words: 192
  • Pages: 2
/* Click the button of the form made in C# to open the desired file */ using using using using

System; System.Windows.Forms; System.Drawing; System.Diagnostics;

class ButtonForm : Form { Button MyButton; Button MyButton2; public ButtonForm() { Text = "Syed Arbab Ahmed Assignment EP-046142"; MyButton = new Button(); MyButton.Text = "Click me to open your desired file"; MyButton.Location = new Point(100, 200); MyButton2 = new Button(); MyButton2.Text = " Click me to open your desired file no. 2"; MyButton2.Location = new Point(100, 100); // Add button event handler to list. MyButton.Click += new EventHandler(MyButtonClick); MyButton2.Click += new EventHandler(MyButton2Click); Controls.Add(MyButton); Controls.Add(MyButton2); } [STAThread] public static void Main() { ButtonForm skel = new ButtonForm(); Application.Run(skel); Application.EnableVisualStyles(); Application.Run(new ButtonForm()); //skel.BackColor = (1,1,1); } // Handler for MyButton. Process TheProcessYouNamed; private void MyButtonClick(object sender, EventArgs e) { { TheProcessYouNamed = Process.Start(@"E:\Check.txt");//@ to avoid Unrecognized escape sequence otherwise ERROR C:\Documents and Settings\tuser\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Program.cs 39

} }

TheProcessYouNamed.CloseMainWindow();

Process TheProcessYouNamed2; private void MyButton2Click(object sender, EventArgs e) { {

TheProcessYouNamed2 = Process.Start(@"c:\RR.txt");//@ to avoid Unrecognized escape sequence otherwise ERROR C:\Documents and Settings\tuser\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Program.cs 39 TheProcessYouNamed2.CloseMainWindow(); } } } /* Syed Arbab Ahmed from Karachi, Pakistan. */

Related Documents


More Documents from ""