private void ListBox_SelectedIndexChanged(object sender, EventArgs e) { ListBox listBox = sender as ListBox; Control container = listBox.Parent; GridButtonProperty gridbtnProperty = container.Controls["_gridbuttonProperty"] as GridButtonProperty; LibGridButton gridbtn = listBox.Items[listBox.SelectedIndex] as LibGridButton; gridbtnProperty.SetPropertyValue(gridbtn, null); //if (!string.IsNullOrEmpty(gridbtn.FromkeyValueID)) //{ // keyValueProperty.Enabled = false; //} //else //{ // keyValueProperty.Enabled = true; //} }
private void Addbtn_Click(object sender, EventArgs e) { Control ctl = sender as Control; Control container = ctl.Parent.Parent; ListBox box = container.Controls["_listbox"] as ListBox; LibGridButton gridbtn = new LibGridButton(); gridbtn.GridButtonID = Guid.NewGuid().ToString(); gridbtn.GridButtonName = string.Format("GridButton{0}", box.Items.Count + 1); gridbtn.GridButtonDisplayNm = string.Format("GridButton{0}", box.Items.Count + 1); //keyValue.ID = Guid.NewGuid().ToString(); //keyValue.Key = string.Format("itemkey{0}", box.Items.Count + 1); //keyValue.Value = string.Format("itemvalue{0}", box.Items.Count + 1); box.Items.Add(gridbtn); GridButtonProperty gridbtnProperty = container.Controls["_gridbuttonProperty"] as GridButtonProperty; gridbtnProperty.SetPropertyValue(gridbtn, null); }