1

我正在创建一个具有默认属性的按钮,除了FlatStyle = 0, BorderSize = 0, MouseDownBackColor = Transparent, MouseOverBackColor = Transparent, BackgroundImageLayout = Stretch

使用我MouseEnter使用以下语法创建的事件

private void SearchBorrowerbutton_MouseEnter(object sender, EventArgs e)
    {

        SearchBorrowerbutton.Image = Properties.Resources.ButtonsShinnig;

    }

MouseLeave语法为

private void SearchBorrowerbutton_MouseLeave(object sender, EventArgs e)
    {
        SearchBorrowerbutton.Image = Properties.Resources.Buttons;
    }

现在我的问题是,每当我的鼠标指向SearchBorrowerbutton图像更改但它不在时,Stretch property我已经尝试过这个

private void SearchBorrowerbutton_MouseEnter(object sender, EventArgs e)
    {
        SearchBorrowerbutton.BackgroundImageLayout = ImageLayout.Stretch;
        SearchBorrowerbutton.Image = Properties.Resources.ButtonsShinnig;

    }
private void SearchBorrowerbutton_MouseLeave(object sender, EventArgs e)
    {
        SearchBorrowerbutton.BackgroundImageLayout = ImageLayout.Stretch;
        SearchBorrowerbutton.Image = Properties.Resources.Buttons;
    }

但它仍然显示在 Tile 属性上

4

1 回答 1

0

问题是BackgroundImageLayout仅适用于,BackgroundImage但您ImageButton代码MouseEnterMouseLeave事件中切换。解决方案是更改ImageBackgroundImage

private void SearchBorrowerbutton_MouseEnter(object sender, EventArgs e)
{
    SearchBorrowerbutton.BackgroundImage = Properties.Resources.ButtonsShinnig;

}
private void SearchBorrowerbutton_MouseLeave(object sender, EventArgs e)
{
    SearchBorrowerbutton.BackgroundImage = Properties.Resources.Buttons;
}
于 2013-07-14T01:44:33.327 回答