0

フォームの読み込みでは、6 つのボタンすべてにこのコードを使用しています

private void Parent_Load(object sender, EventArgs e) 
{ 
btnExam.SetBounds(btnExam.Location.X, btnExam.Location.Y, 175, 154); 
btnResult.SetBounds(btnResult.Location.X, btnResult.Location.Y, 175, 154); 
btnContactUs.SetBounds(btnContactUs.Location.X, btnContactUs.Location.Y, 175, 154); 
btnClasses.SetBounds(btnClasses.Location.X, btnClasses.Location.Y, 175, 154); 
btnCollegeList.SetBounds(btnCollegeList.Location.X, btnCollegeList.Location.Y,175,154); 
btnAbout.SetBounds(btnAbout.Location.X, btnAbout.Location.Y, 175, 154); 

GraphicsPath polygon_path = new GraphicsPath(FillMode.Winding); 
polygon_path.AddPolygon(GetPoints(btnExam.ClientRectangle)); 
polygon_path.AddPolygon(GetPoints(btnResult.ClientRectangle)); 
polygon_path.AddPolygon(GetPoints(btnContactUs.ClientRectangle)); 
polygon_path.AddPolygon(GetPoints(btnClasses.ClientRectangle)); 
polygon_path.AddPolygon(GetPoints(btnCollegeList.ClientRectangle)); 
polygon_path.AddPolygon(GetPoints(btnAbout.ClientRectangle)); 

// Convert the GraphicsPath into a Region. 
Region polygon_region = new Region(polygon_path); 

// Constrain the button to the region. 
btnExam.Region = polygon_region; 
btnResult.Region = polygon_region; 
btnContactUs.Region = polygon_region; 
btnClasses.Region = polygon_region; 
btnCollegeList.Region = polygon_region; 
btnAbout.Region = polygon_region; 

}

すべてのボタンの「MouseEnter_Event」の以下のコード

private void genericButton_event(object sender, EventArgs e) 
{ 
var btn = (Button)sender; 
var imageName = btn.Name; 
btn.Image = (Bitmap)Properties.Resources.ResourceManager.GetObject(imageName); 
}

「MouseLeave_event」で以下のコードを使用しようとすると、指定された画像が取得されないため、画像が取得されません

private void genericButtonLeave_event(object sender, EventArgs e) 
{ 
var btn = (Button)sender; 
var imageName = btn.Name + "L"; 
btn.Image = (Bitmap)Properties.Resources.ResourceManager.GetObject(imageName); 
}

ボタンのホバー画像を変更するために私が行っているのはこれだけです。画像を取得する方法を教えてくださいmouseLeave event。間違いはどこですか

4

0 に答える 0