使用PopupContainerEdit和PopupContainerControl制作下拉菜单树小记

     首先拖动一个PopupContainerEdit控件和PopupContainerControl控件到界面上,在PopupContainerControl中拖动一个TreeList控件,设置TreeList控件的OptionsView属性,我的设置为


使用PopupContainerEdit和PopupContainerControl制作下拉菜单树小记                                       使用PopupContainerEdit和PopupContainerControl制作下拉菜单树小记
 

  设置TreeList控件的OptionsView属性                              设置TreeList的OptionsSelection属性:                   



 


      使用PopupContainerEdit和PopupContainerControl制作下拉菜单树小记                                             使用PopupContainerEdit和PopupContainerControl制作下拉菜单树小记

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

 选择之后便可关闭弹出框。

 
使用PopupContainerEdit和PopupContainerControl制作下拉菜单树小记

补充:为了能让PopupContainerControl和PopupContainerEdit的宽度保持一致,需要在PopupContainerEdit上添加QueryPopUp事件处理:

 

private void popupContainerEdit1_QueryPopUp(object sender, CancelEventArgs e)
{
      PopupContainerEdit popupedit = (PopupContainerEdit)sender;
      popupContainerControl1.Width = popupedit.Width;
}

 


 

你可能感兴趣的:(contain)