一个项目中用到的实例,根据数据库查询出待显示的radioButton的个数,显示在一个新的窗口中。

//动态显示radioButton
public void showRadioButton(int listSize,List<String> list) {
//控件上边缘与容器上边缘的距离
int top = ;
//记录循环,控件左上角相对于容器左上角的坐标
int i = ;
int n = ;
RadioButton[] radioButton = new RadioButton[listSize];
for (n = ; n < listSize; n++)
{
if (n % == && n != )
{
i++;
if (i % == )
{
top = * n;
i = ;
}
else
{
top = ;
}
}
radioButton[n] = new RadioButton();
radioButton[n].AutoSize = true;
radioButton[n].Top = top;
//控件左上角相对于容器左上角的坐标,以及每个控件之间的距离
radioButton[n].Location = new Point(i * + , top);
// MessageBox.Show(name[n].ToString());
radioButton[n].Text = list[n].ToString();
radioButton[n].Visible = true;
radioButton[n].Name = "radioButton" + n;
this.panel1.Controls.Add(radioButton[n]);
top = top + ;
} }

C# 窗体WinForm中动态显示radioButton实例的更多相关文章

  1. C# WinForm 单例模式(例:同一个窗体只创建一次实例)

    //C# WinForm 单例模式(例:同一个窗体只创建一次实例) //打开窗体的事件: Form3 f = Form3.InstanceObject() ; //实例化窗体 f.Focus(); / ...

  2. Winform中如何实现父窗体传递数据到子窗体并刷新子窗体

    原理:利用委托和事件,本文将以图文并茂的例子讲述,告诉我们So Easy --------------------------------------------------------------- ...

  3. WinForm中 Asp.Net Signalr消息推送测试实例

    p{ text-align:center; } blockquote > p > span{ text-align:center; font-size: 18px; color: #ff0 ...

  4. WinForm中一个窗体调用另一个窗体

    [转] WinForm中一个窗体调用另一个窗体的控件和事件的方法(附带源码) //如果想打开一个 Form2 的窗体类,只需要: Form2 form = new Form2(); //有没有参数得看 ...

  5. .net中单选按钮RadioButton,RadioButtonList 以及纯Html中radio的用法实例?

    .net中单选按钮RadioButton,RadioButtonList 以及纯Html中radio的用法,区别? RadioButton实例及说明: <asp:RadioButton ID=& ...

  6. C# winform中 窗体缩放自适应的方法(不同电脑/不同分辨率)

    C# winform中 窗体缩放自适应的方法(不同电脑/不同分辨率)   窗体缩放是一个困扰我多时的问题,为了解决这个问题,我从网上找了很多相关的资料,很多人说用Anchor和Dock属性,但是我试了 ...

  7. c# WinForm窗体编程中对窗体程序设置快捷键

    c# WinForm窗体编程中对窗体程序设置快捷键http://www.cnblogs.com/bison1989/archive/2011/09/19/2180977.html /// <su ...

  8. Winform中怎样跨窗体获取另一窗体的控件对象

    场景 Winform中实现跨窗体获取ZedGraph的ZedGraphControl控件对象: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/de ...

  9. c# winform中窗体切换后释放及防止重复生成

    问题1:窗体切换后如何关闭,并释放资? c# winform中,2个窗体,form1和form2,互相切换的时候执行 this.Hide(); Form2 form2 = new Form2(); f ...

随机推荐

  1. bzoj 1861 treap

    思路:搞搞平衡树. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #def ...

  2. (9) go 时间日期

    1. var t = time.Now() println(t.String())//2019-04-26 13:38:02.5100554 +0800 CST m=+0.000000001 2. 月 ...

  3. .zip格式和zip伪加密

    ZIP文件的组成: 压缩源文件数据区+压缩源文件目录区+压缩源文件目录结束标志 压缩源文件数据区 50 4B 03 04:这是头文件标记(0x04034b50) 14 00:解压文件所需 pkware ...

  4. 【BZOJ 3560】 3560: DZY Loves Math V (欧拉函数)

    3560: DZY Loves Math V Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 241  Solved: 133 Description ...

  5. 「HAOI2015」按位或

    「HAOI2015」按位或 解题思路 : 这类期望题一眼 \(\text{Min-Max}\) 容斥,只需要稍微推一下如何求 \(E(minS)\) 即可. \[ E(minS) = \frac{1} ...

  6. [BZOJ4872][六省联考2017]分手是祝愿(期望DP)

    4872: [Shoi2017]分手是祝愿 Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 516  Solved: 342[Submit][Statu ...

  7. 【bzoj1875】【JZYZOJ1354】[SDOI2009]HH去散步 矩阵快速幂 点边转换

    http://172.20.6.3/Problem_Show.asp?id=1354 http://www.lydsy.com/JudgeOnline/problem.php?id=1875  题意: ...

  8. 【带修改的主席树】BZOJ1901-Dynamic Rankings

    稍后整理笔记.这题数据范围好像有点问题? #include<iostream> #include<cstdio> #include<cstring> #includ ...

  9. arraylist-lambada-性能测试

    package cn.com.one;import java.util.ArrayList;public class ttt { public static void main(String [] a ...

  10. MySQL -- 性能优化的最佳20+条经验

    FROM:http://www.cnblogs.com/shlhm/p/3235848.html ,学习学习~ 今天,数据库的操作越来越成为整个应用的性能瓶颈了,这点对于Web应用尤其明显.关于数据库 ...