form中动态生成Radiobutton控件

public partial class GetLabelFields : Form
    {
        int tableCount;
        public GetLabelFields(AxMapControl axmapcontrol )
        {
            InitializeComponent();
            if(axmapcontrol.LayerCount<=0)
            {
                MessageBox.Show("无图层,请加载图层");
                return;
            }
            ILayer pLayer = axmapcontrol.get_Layer(0);
            IFeatureClass pFeatureClass = ((IFeatureLayer)pLayer).FeatureClass;
            ITable pTable = pFeatureClass as ITable;
            tableCount = pTable.Fields.FieldCount;
            if (tableCount >= 16)
            {
                MessageBox.Show("字段过多,不能全部显示");
            }

            for (int i = 0; i < tableCount-2; i++)
            {

Point pPoint = new Point(20,30*(i+1));
RadioButton radioButton = new RadioButton();
radioButton.Size = new System.Drawing.Size(50,20);
radioButton.Location = pPoint;
radioButton.Text = pTable.Fields.get_Field(i + 2).Name;
this.gbxLabelField.Controls.Add(radioButton);


                radioButton.Show();
            }

        }private void btnOK_Click(object sender, EventArgs e)
        {
                 string filename = null;
            foreach (GroupBox gbxLabelField in this.Controls.OfType<GroupBox>())
            {
                foreach (RadioButton radiobutton in gbxLabelField.Controls.OfType<RadioButton>())
                {
                    if (radiobutton.Checked == true)
                    {
                        filename = radiobutton.Text;
                    }
                }
            }
            this.Tag =(object)filename;
            this.Close();
        }

    }
时间: 2024-08-02 12:16:26

form中动态生成Radiobutton控件的相关文章

动态生成PictureBox控件,涉及:PictureBox控件和flowLayoutPanel面板

一.概述 flowLayoutPanel面板是一系列控件的容器,有关详细的使用方法留待以后总结. 二.问题提出 问题提出:点击按钮,扫描指定文件夹并将其中的所有图片放在flowLayoutPanel面板内.换句话说,就是在flowLayoutPanel面板内动态生成N个PictureBox控件. 此外,还有一个要求,N是变化的,有时显示5个图片,有时显示20个图片.这就要求动态生成新的控件之前先销毁已经存在的控件. 三.销毁代码 销毁控件代码: box[v].Dispose(); box[v]

第二章实例:动态生成View控件例子---小球跟随手指滑动

package mydefault.packge; import android.app.Activity; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; import android.os.Bundle; import androi

通过JavaScript动态生成html控件

示例代码 <html> <head> <meta http-equiv="Content-Type" content="text/html"; charset="utf-8" /> <title>动态生成控件</title> <script> var i=1; function add() { var top = document.getElementById("t

Android在onCreate()方法中动态获取TextView控件的高度

正好朋友项目里遇到了给写了个小Demo: 这个监听器看名字也知道了.就是在绘画完毕之前调用的,在这里面能够获取到行数.当然也能够获取到宽高等信息 package com.example.textviewtest; import android.annotation.SuppressLint; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.Vie

转载 [WPF][C#]在WPF中内嵌WindowsForm控件-使用WindowsFormsControlLibrary

[WPF][C#]在WPF中内嵌WindowsForm控件-使用WindowsFormsControlLibrary 在[WPF][C#]在WPF中内嵌WindowsForm控件一文中为各位介绍了直接在WPF中使用XAML来嵌入Windows Form控件的作法,不过不是每个人都喜欢写XAML,而且有时候会需要把已经存在的Windows Form应用程序嵌入到WPF中,所以这次就来跟大家介绍怎么使用参考dll档的方式,把dll中的Windows Form加到WPF中. 都说了要使用Windows

解决tableView中cell动态加载控件的重用问题

tableView的cell,有时候需要在运行时取得对应的数据后才能够动态的创建该cell中的控件并加载到该cell中,此时,你一定会遇到重用问题,即使你能做到该cell只根据数值加载了一回控件,你也没法保证不出现重用问题:) 效果(请注意查看,移动下面的格子时,上面出现了重用的问题) 源码: YXCell.h // // YXCell.h // YXTableView // // Copyright (c) 2014年 Y.X. All rights reserved. // #import

WinForm用户控件、动态创建添加控件、timer控件--2016年12月12日

好文要顶 关注我 收藏该文 徐淳 关注 - 1 粉丝 - 3 0 0 用户控件: 通过布局将多个控件整合为一个控件,根据自己的需要进行修改,可对用户控件内的所有控件及控件属性进行修改使用 动态创建添加控件: 1 //定义控件类型 2 Button btn = new Button(); 3 //控件名称……等属性,也可以直接绑定各种事件 4 btn.Name = "mybutton" + i.ToString(); 5 //添加到窗体 this 可以替换为 容器控件 6 this.Co

easyui表单多重验证,动态设置easyui控件

要实现的功能:在做添加学生信息的时候,利用easyui的验证功能判断 学号是否重复和学号只能为数字 最终效果如下图: 但在做这个的过程中,遇到了一系列的问题: 扩展validatebox的验证方法,最开始的验证代码如下: 1 //学号格式只能为数字 ****//这里没有问题**** 2 number: {//value值为文本框中的值 3 validator: function (value) { 4 var reg = /^[0-9]*$/; 5 return reg.test(value);

动态加入子控件

我想实现:点击button,动态生成 之前在xml里已经定义好的layout. 自己定义的已经定义好的xml文件: rizhi_pinglun.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/pingl