コード例 #1
0
 private void KeyValuesControl_Load(object sender, EventArgs e)
 {
     this._keyvalus         = ModelDesignProject.GetKeyvaluesByid(this._funNode.Name);
     this._keyvalus.Package = this._funNode.Package;
     if (this._keyvalus != null)
     {
         if (this._keyvalus.KeyValues != null)
         {
             foreach (LibKeyValue item in this._keyvalus.KeyValues)
             {
                 this.listBox1.Items.Add(item);
             }
         }
     }
 }
コード例 #2
0
        private void Frombtn_Click(object sender, EventArgs e)
        {
            string[] allkeyvalues = ModelManager.GetAllKeyValuesNm(string.Empty);
            Panel    p            = new Panel();

            p.Dock       = DockStyle.Fill;
            p.Name       = "pkeyvaluescollection";
            p.AutoScroll = true;
            ListBox listBox = new ListBox();

            listBox.Dock = DockStyle.Fill;
            listBox.Name = "keyvaluelist";
            if (allkeyvalues != null)
            {
                foreach (string kv in allkeyvalues)
                {
                    listBox.Items.Add(kv);
                }
            }
            p.Controls.Add(listBox);

            FieldCollectionForm fielsform = new FieldCollectionForm(p);
            DialogResult        dialog    = fielsform.ShowDialog(this);

            if (dialog == DialogResult.OK)
            {
                string nm = listBox.SelectedItem.ToString();
                LibKeyValueCollection obj = ModelManager.GetKeyValues(nm);

                Control ctl       = sender as Control;
                Control container = ctl.Parent.Parent;
                ListBox box       = container.Controls["_listbox"] as ListBox;
                if (obj != null && obj.KeyValues != null)
                {
                    box.Items.Clear();
                    foreach (LibKeyValue item in obj.KeyValues)
                    {
                        item.FromkeyValueID = nm;
                        box.Items.Add(item);
                    }
                }
            }
        }