Click here to Skip to main content
15,891,473 members
Home / Discussions / C#
   

C#

 
AnswerRe: Is this forum useful any more? Pin
Michael Sync16-Aug-07 16:39
Michael Sync16-Aug-07 16:39 
GeneralRe: Is this forum useful any more? Pin
KrunalC16-Aug-07 16:44
KrunalC16-Aug-07 16:44 
GeneralRe: Is this forum useful any more? Pin
Michael Sync16-Aug-07 16:59
Michael Sync16-Aug-07 16:59 
GeneralRe: Is this forum useful any more? Pin
KrunalC16-Aug-07 17:08
KrunalC16-Aug-07 17:08 
GeneralRe: Is this forum useful any more? Pin
jith - iii16-Aug-07 18:06
jith - iii16-Aug-07 18:06 
GeneralRe: Is this forum useful any more? Pin
Judah Gabriel Himango16-Aug-07 19:05
sponsorJudah Gabriel Himango16-Aug-07 19:05 
GeneralRe: Is this forum useful any more? Pin
jith - iii16-Aug-07 19:21
jith - iii16-Aug-07 19:21 
QuestionTreeView does not show selected node! Pin
Mark F.16-Aug-07 13:17
Mark F.16-Aug-07 13:17 
First of all, I have HideSelection set to false. I implemented drag and drop in a TreeView so that the indexed cards in the tree can be moved manually (cards store book info like Library card files). An XML file is updated with the newly arranged tree. The TreeView is refreshed in the Drag_Drop event, but the SelectedNode does not show!

Is there a workaround for this?

Here's the code...,
<small>private void cardsTreeView_DragDrop( object sender, DragEventArgs e )
{
    nodePosition.X = e.X;
    nodePosition.Y = e.Y;
    nodePosition = cardsTreeView.PointToClient(nodePosition);

    TreeNode dropNode = cardsTreeView.GetNodeAt(nodePosition);

    if (dropNode != null && dropNode.Parent == this.nodeToDelete.Parent)
    {
        TreeNode dragNode = this.nodeToDelete;
        
        if (dropNode == dragNode)
            return;

        dropNode.Parent.Nodes.Remove(this.nodeToDelete);
        dropNode.Parent.Nodes.Insert(dropNode.Index + 1, dragNode);

        Cards.MoveCardTo(GetIndexString(dropNode), GetIndexString(nodeToDelete));
        Cards.ReOrderCards();

        if (cardsTreeView.Nodes.Count > 0)
            cardsTreeView.Nodes.Clear();

        cardsTreeView.BeginUpdate();

        // load all cards from XML document
        Cards.GetAllCards(ref cardsTreeView);

        cardsTreeView.EndUpdate();
        cardsTreeView.ExpandAll();
       
        cardsTreeView.EndUpdate();
        
        // Fails to show the selected node 
        cardsTreeView.SelectedNode = cardsTreeView.Nodes[dropNode.Index];
        cardsTreeView.SelectedNode.EnsureVisible();
    }
}

private void cardsTreeView_DragEnter( object sender, DragEventArgs e )
{
    if(e.Data.GetDataPresent(DataFormats.Text))
        e.Effect = DragDropEffects.Move;
    else
        e.Effect = DragDropEffects.None;
}

private void cardsTreeView_ItemDrag( object sender, ItemDragEventArgs e )
{
    nodeToDelete = (TreeNode) e.Item;
    string strItem = e.Item.ToString();
    DoDragDrop(strItem, DragDropEffects.Copy | DragDropEffects.Move);
}
</small>


Thanks,
Mark
AnswerRe: TreeView does not show selected node! Pin
Mark Churchill16-Aug-07 21:16
Mark Churchill16-Aug-07 21:16 
GeneralRe: TreeView does not show selected node! Pin
Mark F.19-Aug-07 7:28
Mark F.19-Aug-07 7:28 
GeneralRe: TreeView does not show selected node! Pin
Mark Churchill19-Aug-07 15:03
Mark Churchill19-Aug-07 15:03 
GeneralRe: TreeView does not show selected node! Pin
Mark F.20-Aug-07 3:45
Mark F.20-Aug-07 3:45 
QuestionC # Constructor question Pin
radshaykho16-Aug-07 13:15
radshaykho16-Aug-07 13:15 
AnswerRe: C # Constructor question Pin
Colin Angus Mackay16-Aug-07 13:47
Colin Angus Mackay16-Aug-07 13:47 
GeneralRe: C # Constructor question Pin
Paul Conrad16-Aug-07 15:39
professionalPaul Conrad16-Aug-07 15:39 
AnswerRe: C # Constructor question Pin
Luc Pattyn16-Aug-07 13:50
sitebuilderLuc Pattyn16-Aug-07 13:50 
AnswerRe: C # Constructor question Pin
Scott Dorman16-Aug-07 13:52
professionalScott Dorman16-Aug-07 13:52 
Questionbyte[] file to PDF and then send in an email as atachment Pin
mvadibb16-Aug-07 12:12
mvadibb16-Aug-07 12:12 
AnswerRe: byte[] file to PDF and then send in an email as atachment Pin
Guffa16-Aug-07 14:48
Guffa16-Aug-07 14:48 
AnswerRe: byte[] file to PDF and then send in an email as atachment Pin
User 167325216-Aug-07 14:49
User 167325216-Aug-07 14:49 
GeneralRe: byte[] file to PDF and then send in an email as atachment Pin
mvadibb17-Aug-07 5:37
mvadibb17-Aug-07 5:37 
Questionc# - handling events for forms Pin
jon-8016-Aug-07 11:16
professionaljon-8016-Aug-07 11:16 
AnswerRe: c# - handling events for forms Pin
Luc Pattyn16-Aug-07 11:18
sitebuilderLuc Pattyn16-Aug-07 11:18 
GeneralRe: c# - handling events for forms Pin
jon-8016-Aug-07 11:34
professionaljon-8016-Aug-07 11:34 
GeneralRe: c# - handling events for forms Pin
Luc Pattyn16-Aug-07 11:50
sitebuilderLuc Pattyn16-Aug-07 11:50 

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.