c# winform 中flowlayoutpanel 绘制分页按钮剧居中

flowlayoutpanel.AutoSize=True; 

 

private void MyProject_Paint(object sender, PaintEventArgs e)
        {
           //重绘分页按钮坐标
            int formWidth = this.Width;
            int pageWidth = this.flowLayoutPanelPage.Width;
            int moveLenght = (formWidth - pageWidth) / 2;
            if (pageWidth > formWidth / 2)
            {
                this.flowLayoutPanelPage.Location = new Point(moveLenght, 526);
            }
            else if (pageWidth < formWidth / 2)
            {
                int move = formWidth/2 - pageWidth / 2;
                this.flowLayoutPanelPage.Location = new Point(move, 526);
            }
            else
            {
                int move = pageWidth / 2;
                this.flowLayoutPanelPage.Location = new Point(move, 526);
            }
            flowLayoutPanelPage.Visible = true;
        }

你可能感兴趣的:(c#)