码迷,mamicode.com
首页 > Windows程序 > 详细

窗体之间传值

时间:2015-02-19 15:05:44      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:

传值可在副窗口cs中定义副窗口的Tag属性,结合主窗口cs中的:副窗口类名.ActiveForm.Tag属性//进行传递。

同时须结合主窗口中定义的副窗口的FormClosing方法。

private void 显示标注ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //没有图层时,报提示框
            if (axMapControl1.LayerCount <= 0)
            {
                MessageBox.Show("当前无图层,无法显示标注");
                return;
            }

            if (i3 % 2 == 0)
            {
                ((IGeoFeatureLayer)axMapControl1.get_Layer(0)).DisplayAnnotation = false;
                i3++;
                this.显示标注ToolStripMenuItem.Text = "显示标注";
                axMapControl1.Refresh();
                return;
            }

            GetLabelFields pGetLabelFields = new GetLabelFields(axMapControl1);
            pGetLabelFields.Show();
            pGetLabelFields.FormClosing += new FormClosingEventHandler(pGetLabelFields_FormClosing);

            
        }

        void pGetLabelFields_FormClosing(object sender, FormClosingEventArgs e)
        {
            ILayer pLayer = (IGeoFeatureLayer)axMapControl1.get_Layer(0);
            string filename = null;
            filename = (string)(GetLabelFields.ActiveForm.Tag);
            AddAnnotate.ToAddAnnotate(pLayer, filename);
            axMapControl1.Refresh();
            i3++;
            this.显示标注ToolStripMenuItem.Text = "还原";
        }

 

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();
        }

 

窗体之间传值

标签:

原文地址:http://www.cnblogs.com/xianerwonder/p/4296103.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!