Click here to Skip to main content
15,892,927 members
Home / Discussions / C#
   

C#

 
AnswerRe: Changing Win XP Registry via C# Pin
Mycroft Holmes21-Jan-09 20:46
professionalMycroft Holmes21-Jan-09 20:46 
Questionglobal.aspx Pin
santoshsavita21-Jan-09 19:48
santoshsavita21-Jan-09 19:48 
AnswerRe: global.aspx Pin
Harvey Saayman21-Jan-09 19:52
Harvey Saayman21-Jan-09 19:52 
QuestionDrag and Drop Treeview Item into listview Pin
Udayaraju21-Jan-09 19:36
Udayaraju21-Jan-09 19:36 
AnswerRe: Drag and Drop Treeview Item into listview Pin
Udayaraju22-Jan-09 0:31
Udayaraju22-Jan-09 0:31 
AnswerRe: Drag and Drop Treeview Item into listview Pin
DaveyM6922-Jan-09 1:51
professionalDaveyM6922-Jan-09 1:51 
GeneralRe: Drag and Drop Treeview Item into listview Pin
Udayaraju22-Jan-09 3:01
Udayaraju22-Jan-09 3:01 
GeneralRe: Drag and Drop Treeview Item into listview Pin
DaveyM6922-Jan-09 4:07
professionalDaveyM6922-Jan-09 4:07 
Check out the working code below and compare - you should be able to figure it out from this.
/* Assumes
TreeView treeView1. Parent node must have Tag "Parent" and
exactly two child nodes for drag to work
ListView listView1 with three columns already added.

Events subscribed
treeView1.ItemDrag += new ItemDragEventHandler(treeView1_ItemDrag);
listView1.DragOver += new DragEventHandler(listView1_DragOver);
listView1.DragDrop += new DragEventHandler(listView1_DragDrop);
*/
void treeView1_ItemDrag(object sender, ItemDragEventArgs e)
{
    TreeNode nodeData = (TreeNode)e.Item;
    // set as selected
    treeView1.SelectedNode = nodeData;
    // check is parent using tag property
    if ((string)nodeData.Tag == "Parent" && nodeData.Nodes.Count == 2)
        // OK
        treeView1.DoDragDrop(nodeData, DragDropEffects.Copy);
}
void listView1_DragOver(object sender, DragEventArgs e)
{
    // default to none
    e.Effect = DragDropEffects.None;
    // get tree node
    TreeNode nodeData = (TreeNode)e.Data.GetData(typeof(TreeNode));
    // check data in case coming from elsewhere
    if (nodeData != null && (string)nodeData.Tag == "Parent" && nodeData.Nodes.Count == 2)
        // OK so proceed
        e.Effect = DragDropEffects.Copy;

}
void listView1_DragDrop(object sender, DragEventArgs e)
{
    // get tree node
    TreeNode nodeData = (TreeNode)e.Data.GetData(typeof(TreeNode));
    // check data
    if (nodeData != null && (string)nodeData.Tag == "Parent" && nodeData.Nodes.Count == 2)
    {
        // convert
        ListViewItem newItem = new ListViewItem(nodeData.Text);
        foreach (TreeNode childNode in nodeData.Nodes)
        {
            ListViewItem.ListViewSubItem newSub = new ListViewItem.ListViewSubItem();
            newSub.Text = childNode.Text;
            // add children to parent
            newItem.SubItems.Add(newSub);
        }
        // add parent
        listView1.Items.Add(newItem);
    }
}


Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

GeneralRe: Drag and Drop Treeview Item into listview Pin
Udayaraju22-Jan-09 4:14
Udayaraju22-Jan-09 4:14 
QuestionRe: Drag and Drop Treeview Item into listview Pin
Udayaraju22-Jan-09 4:10
Udayaraju22-Jan-09 4:10 
QuestionIssue with the Windows Service OnTimeElapsed Pin
mpavas21-Jan-09 19:33
mpavas21-Jan-09 19:33 
AnswerRe: Issue with the Windows Service OnTimeElapsed Pin
Guffa21-Jan-09 21:51
Guffa21-Jan-09 21:51 
GeneralRe: Issue with the Windows Service OnTimeElapsed Pin
mpavas21-Jan-09 21:57
mpavas21-Jan-09 21:57 
GeneralRe: Issue with the Windows Service OnTimeElapsed Pin
mpavas21-Jan-09 22:18
mpavas21-Jan-09 22:18 
GeneralRe: Issue with the Windows Service OnTimeElapsed Pin
Guffa22-Jan-09 0:45
Guffa22-Jan-09 0:45 
AnswerRe: Issue with the Windows Service OnTimeElapsed Pin
#realJSOP22-Jan-09 0:21
mve#realJSOP22-Jan-09 0:21 
GeneralRe: Issue with the Windows Service OnTimeElapsed Pin
S. Senthil Kumar22-Jan-09 3:27
S. Senthil Kumar22-Jan-09 3:27 
Questionhow to make gridview1 inside gridview2 inside gridview3 Pin
thanhtike21-Jan-09 19:25
thanhtike21-Jan-09 19:25 
QuestionHow do you name controls? Pin
CooperWu21-Jan-09 19:14
CooperWu21-Jan-09 19:14 
AnswerRe: How do you name controls? Pin
Vikram A Punathambekar21-Jan-09 20:00
Vikram A Punathambekar21-Jan-09 20:00 
GeneralRe: How do you name controls? Pin
CooperWu21-Jan-09 21:14
CooperWu21-Jan-09 21:14 
AnswerRe: How do you name controls? Pin
DaveyM6921-Jan-09 21:34
professionalDaveyM6921-Jan-09 21:34 
AnswerRe: How do you name controls? Pin
#realJSOP22-Jan-09 0:24
mve#realJSOP22-Jan-09 0:24 
GeneralRe: How do you name controls? Pin
CooperWu22-Jan-09 14:47
CooperWu22-Jan-09 14:47 
QuestionHow to get device state(enable or disable)? Pin
lovnin21-Jan-09 18:45
lovnin21-Jan-09 18:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.