| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1926 人关注过本帖
标题:请教各位大侠 如何实现Treeview控件中内容到Listbox控件的拖曳
只看楼主 加入收藏
chenxu215213
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-11-14
收藏
 问题点数:0 回复次数:1 
请教各位大侠 如何实现Treeview控件中内容到Listbox控件的拖曳
void __fastcall TForm1::ListBox2DragOver(TObject *Sender, TObject *Source,
      int X, int Y, TDragState State, bool &Accept)
{
    if (Source == ListBox1)
        Accept = TRUE;      // If The Drag source is listbox1 then accept it
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ListBox2DragDrop(TObject *Sender, TObject *Source,
      int X, int Y)
{
    if (Source == ListBox1) // If the source is ListBox1 then deal the drag event
    {
        ListBox2->Items->Add(ListBox1->Items->Strings[ListBox1->ItemIndex]);
    }
}

上面是Listbox控件间的拖曳范例(拖曳源内容拖曳后仍存在)   现在是想从一个Treeview控件选中节点内容拖到Listbox控件 该如何修改啊?  我是初学者  大家提提意见 谢谢啊!
搜索更多相关主题的帖子: 控件 Listbox Treeview 拖曳 
2010-11-14 21:58
rainbow1
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:2
帖 子:277
专家分:839
注 册:2010-5-19
收藏
得分:0 
void __fastcall TForm1::TreeviewDragOver(TObject *Sender, TObject *Source,
      int X, int Y, TDragState State, bool &Accept)
{
    if (Source == TreeView)
        Accept = TRUE;      // If The Drag source is treeview then accept it
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ListBoxDragDrop(TObject *Sender, TObject *Source,
      int X, int Y)
{
    if (Source == TreeView) // If the source is TreeView then deal the drag event
    {
        ListBox->Items->Add(TreeView->Items->Strings[TreeView->ItemIndex]);
    }
}

标红的是关键,实际上是实现了从TreeView对应的节点内容添加到ListBox相应节点。但原节点内容并没有删除。
2010-12-27 23:34
快速回复:请教各位大侠 如何实现Treeview控件中内容到Listbox控件的拖曳
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011284 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved