본문 바로가기

Programing (프로그래밍)

VB.NET - 키보드 이벤트를 버튼 클릭 이벤트로 넘기기 ( KeyPreview / KeyDown / Form ) VB.NET - 키보드 이벤트를 버튼 클릭 이벤트로 넘기기 ( KeyPreview / KeyDown / Form ) '키보드이벤트'를 '버튼클릭' 이벤트로 넘기기 1 2 3 4 5 Private Sub frmMain_KeyDown(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown If e.KeyCode = Keys.F5 Then tsbSet_Click(sender, e) End If End Sub Colored by Color Scripter cs * form 의 경우 폼속성의 'KeyPreview'를 'True' 로 바꿔줘야 한다. 더보기
WPF & C# - OSK 화상키보드 실행하기 ( 가상키보드 ) WPF & C# - OSK 화상키보드 실행하기 ( 가상키보드 ) using System.Diagnostics; using System.IO; var path64 = System.IO.Path.Combine(Directory.GetDirectories(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "winsxs"), "amd64_microsoft-windows-osk_*")[0], "osk.exe"); var path32 = @"C:\windows\system32\osk.exe"; var path = (Environment.Is64BitOperatingSystem) ? path64 : path32; i.. 더보기
WPF & C# - ComboBox & Enum 사용법 ( 콤보박스, 드롭박스, DropBox ) WPF & C# - ComboBox & Enum 사용법 ( 콤보박스, 드롭박스, DropBox ) MainWindow.xaml MainWindow.xaml.cs public MainWindow() { InitializeComponent(); // 입력방식 : enum 명칭 ( Naver, Kakao, Google ) cbx01.ItemsSource = Enum.GetValues(typeof(enumServer)); } enum enumServer { Naver = 1, Kakao, Google = 4 } enumServer selectServer; private void cbx01_SelectionChanged(object sender, SelectionChangedEventArgs e) { if(sel.. 더보기
WPF & C# - List<string> 동적 배열 ( 리스트 / array / dictionary ) WPF & C# - List 동적 배열 추가, 삭제 ( 리스트 / array / dictionary / AddRange / RemoveAll ) 파일읽고 라인별로 배열에 넣기 List list = new List(); string saveFile = @"data.txt"; using (StreamReader sw = new StreamReader(saveFile)) // 파일 읽기 { list.AddRange(sw.ReadToEnd().Split('\n','\r')); // 라인별로 배열에 넣기 list.RemoveAll(s => s.Trim() == ""); // 빈 문자열은 배열에서 삭제 } 참고 insurang.tistory.com/259 더보기
WPF & C# - TextBox 에서 ContextMenu 변경하기 ( SelectedText / 텍스트선택 / 마우스우클릭메뉴 ) WPF & C# - TextBox 에서 ContextMenu 변경하기 ( SelectedText / 텍스트선택 / 마우스우클릭메뉴 ) public MainWindow() { InitializeComponent(); CreateTextBox(); // TextBox 생성 } void CreateTextBox() { // TextBox 생성 TextBox tbx = new TextBox(); tbx.Text = "123456789"; tbx.FontSize = 20; grdMain.Children.Add(tbx); // 컨텍스트메뉴 생성 ( ContextMenu ) ContextMenu contextmenu = new ContextMenu(); MenuItem mid = new MenuItem(); mid... 더보기
WPF & C# - RoundButton ( 둥근버튼 만들기 / CornerRadius / Style ) WPF & C# - RoundButton ( 둥근버튼 만들기 / CornerRadius / Style ) RoundButton ( 둥근버튼 만들기 / CornerRadius / Style ) 두가지 방법이다. 하나는 로컬리소스 Resources 에 넣어서 여러버튼에 동일하게 적용할 시 유용하게 쓰는 방법과 다른하나는 태그로 직접넣어서 한두개 버튼에 쉽게 적용하는 방법이다. 태그 아래에 넣는 방법 리소스에 넣는 방법 Border 부분에 CornerRadius="15" 코드를 넣어주면 된다. 더보기
WPF & C# - Grid 만들기 WPF & C# - Grid 만들기 public MainWindow() { InitializeComponent(); Init(); } void Init() { int numGrd = 0; // 생성된 grid 갯수 int intTotal = 9; // 생성하려는 grid 갯수 int intStartNum = 4; // 시작위치 int intGaro = 10; // 가로 열 갯수 // 가로 열 생성 for (int colum = 0; colum < intGaro; colum++) { bgGrd.ColumnDefinitions.Add(new ColumnDefinition()); } // 세로 행 생성 for (int y = 0; y < ((intTotal-1 + intStartNum ) / intGaro) .. 더보기
WPF & C# - struct 구조체 WPF & C# - struct 구조체 struct Test { public int x; public int y; public int z; } private void Button_Click(object sender, RoutedEventArgs e) { Test a = new Test(); a.x = 1; a.y = 2; a.z = 3; lbl01.Content = a.x; lbl02.Content = a.y; lbl03.Content = a.z; } 더보기