zoukankan      html  css  js  c++  java
  • 窗体之间传值

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

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

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

    
    
     
    GetLabelFields类的代码没有传上来,实际上就是一个动态获得图层字段并且展示出来,前面带有radio的一个窗口,让用户选择一个字段。

  • 相关阅读:
    Spring jdbcTemplat 写入BLOB数据为空
    Android强制弹出,隐藏输入法.
    Android NDK开发篇(五):Java与原生代码通信(数据操作)
    AIX加入�能够telnet远程连接账号方法
    index of rmvb mp3 rm突破站点入口下载
    C++“窗体”程序设计启蒙(之二)
    C++ Primer 学习笔记_72_面向对象编程 --句柄类与继承[续]
    (a*b)%c 小的技巧
    javascript(arguments)
    Cocos2dx 小技巧(十四)ScrollView实现缩放效果
  • 原文地址:https://www.cnblogs.com/xianerwonder/p/4296103.html
Copyright © 2011-2022 走看看