728x90
반응형

[예제1]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Console;
using System.Drawing;
namespace ConsoleApp5
{
    class MainApp : Form
    {
        Random rand;
        public MainApp()
        {
            rand = new Random();
            this.MouseWheel += new MouseEventHandler(f1);
            this.MouseDown += new MouseEventHandler(f2);
        }
        void f1(object sender, MouseEventArgs e) {}
        void f2(object sender, MouseEventArgs e)
        {
            string file = "tiger.bmp"; // 이미지파일
            if (System.IO.File.Exists(file) == false)
            {
                WriteLine("not found");
            }
            else
            {
                WriteLine("found");
                //using System.Drawing;
                this.BackgroundImage = Image.FromFile(file);
            }
        }
        static void Main(string[] args)
        {
            System.Windows.Forms.Application.Run(new MainApp());
        }
    }
}

728x90
반응형

'Education > Edu | .net' 카테고리의 다른 글

# 33) [C#] Winform 3 (VS2017에서 Oracle11g로 데이터 연동)  (0) 2021.03.03
# 32) [C#] Winform 2  (0) 2021.03.02
# 30) [C#] 문법13 (thread)  (0) 2021.02.26
# 29.2) [C#] 문법12  (0) 2021.02.24
# 29.1) [C#] 문법12 (delegate)  (0) 2021.02.24

+ Recent posts