c# - 如何创建可以在 Windows 窗体中单击的黑色矩形?
问题描述
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
System.Drawing.Graphics formGraphics;
formGraphics = this.CreateGraphics();
for (int ii = 0; ii != (10); ii++)
{
for (int i = 0; i != (10); i++)
{
formGraphics.FillRectangle(myBrush, new Rectangle(i * 30, ii*30, 20, 20));
}
}
myBrush.Dispose();
formGraphics.Dispose();
我正在尝试编写扫雷代码。我基本上是在尝试创建一组用户可以单击的矩形,但是当我尝试使用上面的代码时,我所拥有的只是一组用户无法与之交互的 10x10 矩形。
解决方案
推荐阅读
- python - 函数调用堆栈:train_function 错误
- matrix - 可以用 scale + rotate3d 替换 skew
- aem - AEM 使用 HTL 的不同方式
- linux - os.Stdout 和 os.File 有什么区别
- rust - FnOnce 的泛型,返回具有生命周期的未来
- oracle19c - Oracle 数据泵导入 TSTZ 版本
- kubernetes - kubectl - 如何使用基本身份验证从 url 创建资源
- yii2 - yii2 - 多行从一个表单加载到同一个表中
- node.js - 错误处理程序 expressjs 中间件未捕获错误
- python - 如何删除缺少 xpath 文本的 AttributeError?