使用条件将数字传递给连续按钮 [英] Passing numbers to consecutive buttons with a Condition

查看:77
本文介绍了使用条件将数字传递给连续按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我这里有2个变量,一天是一个月中的天数,每周的天数,(星期日= 1,星期一= 2等等),比如说我有30天的时间显示,我会按顺序显示按钮,有没有办法以这种方式显示它?



例子



天= 30

数= 2('这是星期一)



i想要显示它这个



Hi guys , i have 2 variables here, the day which is the number of day in a month, and the number of day per week, (sunday = 1, monday = 2 and so on), lets say for example i have 30 days to display and i will display it to buttons in order , is there any possible way to display it this way?

example

day = 30
number = 2 (' which is monday)

i want to display it like this

NULL 1  2  3   4   5   6 
   7 8  9  10  11  12  13
  14 15 16 17  18  19  20



等等,



这一天的容器是按钮,


对于noob问题抱歉:)


and so on,

containers of the day here are buttons,

sorry for the noob question :)

推荐答案

你可以,而且不难 - 只需设置Text属性依次按每个按钮。

但是......为什么不修复文本而只是移动按钮?

设置31个按钮,(说实话我'这样做动态无论如何,因为我很懒惰)并将它们存储在数组中。

然后,找到本月第一天的DOW,并将其偏移按钮的宽度以找到初始X坐标。循环浏览每个按钮:设置X和Y位置,然后将按钮宽度添加到X.如果您刚刚执行了一周中的最后一天,请将X设置为零,并按按钮高度增加Y.

重复。



完成!
You can, and it's not difficult - just set the Text property of each button in turn.
But...why not just fix the text and just move the buttons?
Set up 31 buttons, (and to be honest I'd do that dynamically anyway, because I'm lazy) and store them in an array.
Then, find the DOW for the first of the month, and offset it by the width of the buttons to locate the initial X coordinate. Loop through each button: Set the X and Y location, then add the button width to the X. If you just did the last day of the week, set X to zero, and increase Y by the button height.
Repeat.

Done!


这篇关于使用条件将数字传递给连续按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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