2014-11-23 2 views
0

그래서 메모장에서 아주 간단한 응용 프로그램을 만들고 있습니다. ++ 지금은 CMD와 같습니다! Visual Studio없이이 C# 응용 프로그램에 UI를 추가하려면 어떻게합니까? Google은 Visual Studio 튜토리얼 만 제공하며 IDE없이 프로그래밍 할 수 있기를 원합니다. 또한 C#에서 간단한 버튼을 추가하는 예를 들어주세요.IDE없이 UI를 추가하는 방법은 무엇입니까?

+1

왜 Visual Studio를 사용하지 않고이 작업을 수행 하시겠습니까? 당신은 무료로 익스프레스 버전을 얻을 수 있습니다. – Tim

+0

간단한 버튼을 무엇에 추가할까요? 아직 추가 할 창이 없습니다. 먼저 처리해야합니다. – hvd

+0

왜 Visual Studio를 사용할 수 없습니까? – thumbmunkeys

답변

1

Visual Studio는 응용 프로그램 용 UI를 생성하는 플러그인이 아니므로 메모장에서이 작업을 수행 할 수도 있습니다. 당신이 사용하거나 찾아야 할 것은 이러한 기능을 사용할 수있는 프레임 워크입니다.

.NET Framework에서 Windows Forms 또는 Windows Presentation Foundation을 사용하여 Button, TextBox 및 TextBlock 컨트롤이있는 응용 프로그램을 만들 수 있습니다. 자신의 IDE에서 이러한 프레임 워크로 작업해야하는 어셈블리를 얻을 수도 있습니다.

WPF 또는 승리 양식의 버튼

은 간단

// create the button instance for your application 
Button button = new Button(); 
// add it to form or UI element; depending on the framework you use. 

입니다 ..하지만 당신은 그 프레임 워크는 Web Froms 또는 MSDN에 WPF로 볼 수, 추가 가지고 있어야합니다. 프레임 워크를 설치하고 메모장 ++에 추가하여 메모장 ++에서 사용할 수 있습니다.

3

모든 Forms/UI 코드를 직접 작성하고 이벤트/로직 코드를 관리해야합니다.

다음은 메시지 상자를 보여주는 버튼이있는 간단한 양식입니다. stackoverflow herehere에 대한 답변으로 다른 예를 볼 수 있습니다.

using System; 
using System.Drawing; 
using System.Windows.Forms; 

namespace CSharpGUI { 
    public class WinFormExample : Form { 

     private Button button; 

     public WinFormExample() { 
      DisplayGUI(); 
     } 

     private void DisplayGUI() { 
      this.Name = "WinForm Example"; 
      this.Text = "WinForm Example"; 
      this.Size = new Size(150, 150); 
      this.StartPosition = FormStartPosition.CenterScreen; 

      button = new Button(); 
      button.Name = "button"; 
      button.Text = "Click Me!"; 
      button.Size = new Size(this.Width - 50, this.Height - 100); 
      button.Location = new Point(
       (this.Width - button.Width)/3 , 
       (this.Height - button.Height)/3); 
      button.Click += new System.EventHandler(this.MyButtonClick); 

      this.Controls.Add(button); 
     } 

     private void MyButtonClick(object source, EventArgs e) { 
      MessageBox.Show("My First WinForm Application"); 
     } 

     public static void Main(String[] args) { 
      Application.Run(new WinFormExample()); 
     } 
    } 
} 
관련 문제