コード例 #1
0
        private void Button_ValueChanged(object sender, bool value)
        {
            UIRadioButton button = (UIRadioButton)sender;

            if (value)
            {
                SelectedIndex = button.Tag.ToString().ToInt();
            }
        }
コード例 #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (Items.Count == 0)
            {
                return;
            }
            if (Items.Count != buttons.Count)
            {
                ClearButtons();

                for (int i = 0; i < Items.Count; i++)
                {
                    UIRadioButton button = new UIRadioButton
                    {
                        Font   = Font,
                        Parent = this,
                        Tag    = i,
                        Style  = Style
                    };

                    button.ValueChanged += Button_ValueChanged;
                    buttons.Add(button);
                }
            }

            int startX = StartPos.X;
            int startY = TitleTop + StartPos.Y;

            for (int i = 0; i < Items.Count; i++)
            {
                buttons[i].Text = Items[i].ToString();

                int rowIndex    = i / ColumnCount;
                int columnIndex = i % ColumnCount;

                buttons[i].Left = startX + ItemSize.Width * columnIndex + ColumnInterval * columnIndex;
                buttons[i].Top  = startY + ItemSize.Height * rowIndex + RowInterval * rowIndex;
                buttons[i].Show();
            }
        }