【发布时间】:2020-07-22 04:12:57
【问题描述】:
我想使用按钮将图像从第一张更改为第二张。启动我的表单时,应始终加载第一张图像,按下按钮后图像与第二张交换,反之亦然。我怎么能这样做?
图片由imgbox加载,没有代码。所有图像都存储在一个名为资源的文件夹中。 Form1.cs 代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WMPLib;
namespace WindowsFormsApp4
{
public partial class Form1 : Form
{
WindowsMediaPlayer player = new WindowsMediaPlayer();
public Form1()
{
InitializeComponent();
player.URL = "tada.mp3";
}
private void pictureBox1_Click(object sender, EventArgs e)
{
player.controls.play();
}
private void changebutton_Click(object sender, EventArgs e)
{
}
private void Form1_HelpButtonClicked(Object sender, CancelEventArgs e)
{
MessageBox.Show("PZP - Przeglądarka zdjęć P0150Na", "Informacje", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
此致
p0150n
【问题讨论】:
-
您是否为您的按钮添加了点击处理程序?
-
是的,我做到了。我不知道下一步该做什么。
-
请提供您的代码sn-p。
-
private void changebutton_Click(object sender, EventArgs e) { }命名空间中的其余内容是用于单击帮助按钮并在启动时播放声音的代码。没有错误或警告。 -
请通过单击编辑在您的帖子中包含您的事件处理程序代码...我们将对您用于更改图像的逻辑感兴趣...您评论中的代码没有t 实际上做任何事情......所以我们需要查看您的其余代码。即:您如何显示默认图像以及其他图像的存储位置。