如何创建一个5/5矩阵以及如何在c#代码中交换按钮(不同位置) [英] how to create a 5 /5 matrix and how to swap button (diffferent location) in c# code

查看:195
本文介绍了如何创建一个5/5矩阵以及如何在c#代码中交换按钮(不同位置)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在空白区域创建一个24按钮和im交换按钮,这样我能做什么..........

i am create a 24 button and i m swap button in a blank space so what can i do ..........

推荐答案

滑动方形拼图,任何机会? :笑:



如果这是您想要的方式,使用按钮上的图像(我不一定会因为它会很难做到之后滑动动画然后最简单的方法就是不要移动按钮!

相反,在两个按钮之间交换图像。

设置第25个按钮显示空白方块,并将点击按钮中的图像复制到其中。然后将单击的按钮设置为空白图像。



这样,您所要做的就是为所有按钮设置单击事件处理程序,并且环顾点击的按钮位置找到空白的方块 - 无论如何你需要做什么!



但是我不会使用按钮:我会使用面板和绘图图像分割自己。这是一个更开始的工作,但你会得到一个更灵活的系统,可以用6 * 6,7 * 7等更好地复制。稍后可以使用网格。使用按钮,这是PITA!
Sliding square puzzle, by any chance? :laugh:

If this is the way you want to go, using images on buttons (and I wouldn't necessarily as it will make it very difficult to do a "sliding" animation later) then the easiest way is not to move the buttons at all!
Instead, swap the images between two buttons.
Set up a 25th button which shows the "blank" square, and copy the image from the clicked button into it. Then set the clicked button to the "blank" image.

That way, all you have to do is set up a single click event handler for all the buttons, and look round the clicked button location to find the blank square - which you need to do anyway!

But I wouldn't use buttons: I'd use panel and draw the image segments myself. It's more work to start with, but you get a more flexible system which copies better with 6*6, 7*7, etc. Grids later on. With buttons, that's a PITA!


这篇关于如何创建一个5/5矩阵以及如何在c#代码中交换按钮(不同位置)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆