转自:http://jlcon.iteye.com/blog/898210
首先拖动一个PopupContainerEdit控件和PopupContainerControl控件到界面上,在PopupContainerControl中拖动一个TreeList控件,设置TreeList控件的OptionsView属性,我的设置为
设置TreeList控件的OptionsView属性 设置TreeList的OptionsSelection属性:
设置TreeList的OptionsBehavior属性,使其不可编辑: 然后设置PopupContainerEdit的PopControl属性
使其与PopupContainerControl组件关联
为TreeList添加FocusedNodeChanged事件
- private void treeList2_FocusedNodeChanged(object sender, FocusedNodeChangedEventArgs e)
- {
- TreeListNode node = e.Node;
- popupContainerEdit1.Tag = node["xxxx"].ToString();
- popupContainerEdit1.EditValue = node[0].ToString();
- popupContainerEdit1.ClosePopup();
- }
选择之后便可关闭弹出框。
补充:为了能让PopupContainerControl和PopupContainerEdit的宽度保持一致,需要在PopupContainerEdit上添加QueryPopUp事件处理:
- private void popupContainerEdit1_QueryPopUp(object sender, CancelEventArgs e)
- {
- PopupContainerEdit popupedit = (PopupContainerEdit)sender;
- popupContainerControl1.Width = popupedit.Width;
- }