Click here to Skip to main content
15,890,579 members
Home / Discussions / C#
   

C#

 
AnswerRe: It doesnt download every file Pin
Member 21681039-Feb-11 0:56
Member 21681039-Feb-11 0:56 
GeneralRe: It doesnt download every file Pin
#realJSOP9-Feb-11 5:41
mve#realJSOP9-Feb-11 5:41 
QuestionRe: It doesnt download every file Pin
Member 216810325-Feb-11 3:35
Member 216810325-Feb-11 3:35 
AnswerRe: It doesnt download every file Pin
Pete O'Hanlon9-Feb-11 1:01
mvePete O'Hanlon9-Feb-11 1:01 
GeneralRe: It doesnt download every file Pin
Luc Pattyn9-Feb-11 1:32
sitebuilderLuc Pattyn9-Feb-11 1:32 
GeneralRe: It doesnt download every file Pin
Pete O'Hanlon9-Feb-11 2:17
mvePete O'Hanlon9-Feb-11 2:17 
GeneralRe: It doesnt download every file Pin
#realJSOP9-Feb-11 5:42
mve#realJSOP9-Feb-11 5:42 
QuestionCopy TreeViewItem WPF .NET 4.0 Pin
Mc_Topaz8-Feb-11 23:02
Mc_Topaz8-Feb-11 23:02 
I try to copy a TreeViewItem with all of it's items from a TreeView. When I try to paste it in the same TreeView but in an other location, I stumble on an error. This is my sample of the relevant code:

Some usefull datatypes
TreeView tvFolders;         // The TreeView object
TreeViewItem bufferFolder;  // A buffer object to store the copied TreeViewItem in


The method to copy the selected TreeViewItem
private void Copy(object sender, RoutedEventArgs e)
{
    if (tvFolders.SelectedItem == null)
        return;

    bufferFolder = tvFolders.SelectedItem as TreeViewItem;
}


The method to paste the selected TreeViewItem
private void Paste(Object sender, RoutedEventArgs e)
{
    if (bufferFolder == null || tvFolders.SelectedItem == null)
        return;

    TreeViewItem selectedFolder = tvFolders.SelectedItem as TreeViewItem;
    selectedFolder.Items.Add(bufferFolder);
}


When I try to execute the selectedFolder.Items.Add(bufferFolder); instruction in the Paste() method, I get an InvalidOperationException with this following message:
"Element already has a logical parent. It must be detached from the old parent before it is attached to a new one."

The only way I know to "detach" the TreeViewItem is to remove it in Copy() method. But doing that actually redesigns the Copy() method to my Cut() method. That is not what I want, but it makes the Paste() method to work D'Oh! | :doh:

I have tried several ways to copy the TreeViewItem with: "deep copy", "shallow copy", a derivided class of TreeViewItem with Serializable attribute and ISerializable interface as well as using the ICloneable interface but I have not had any luck.

Any suggestions for a soluation?
AnswerRe: Copy TreeViewItem WPF .NET 4.0 Pin
Pete O'Hanlon9-Feb-11 1:11
mvePete O'Hanlon9-Feb-11 1:11 
GeneralRe: Copy TreeViewItem WPF .NET 4.0 Pin
Mc_Topaz9-Feb-11 1:38
Mc_Topaz9-Feb-11 1:38 
GeneralRe: Copy TreeViewItem WPF .NET 4.0 Pin
Pete O'Hanlon9-Feb-11 2:11
mvePete O'Hanlon9-Feb-11 2:11 
QuestionVideo Streaming Pin
Rei ho8-Feb-11 18:27
Rei ho8-Feb-11 18:27 
AnswerRe: Video Streaming Pin
Abhinav S8-Feb-11 18:51
Abhinav S8-Feb-11 18:51 
GeneralRe: Video Streaming Pin
Rei ho8-Feb-11 19:35
Rei ho8-Feb-11 19:35 
QuestionHow to send files with http protocol between 2 pc or many Pin
omercansasal8-Feb-11 3:52
omercansasal8-Feb-11 3:52 
AnswerRe: How to send files with http protocol between 2 pc or many PinPopular
Luc Pattyn8-Feb-11 3:56
sitebuilderLuc Pattyn8-Feb-11 3:56 
GeneralRe: How to send files with http protocol between 2 pc or many Pin
omercansasal8-Feb-11 4:16
omercansasal8-Feb-11 4:16 
GeneralRe: How to send files with http protocol between 2 pc or many PinPopular
Luc Pattyn8-Feb-11 4:20
sitebuilderLuc Pattyn8-Feb-11 4:20 
Questionadding a custoncontrol to a form in .net CF . Pin
prasadbuddhika8-Feb-11 0:10
prasadbuddhika8-Feb-11 0:10 
AnswerRe: adding a custoncontrol to a form in .net CF . Pin
Not Active8-Feb-11 2:30
mentorNot Active8-Feb-11 2:30 
Questionmy mysql database string connection Pin
Pierre besquent7-Feb-11 22:42
Pierre besquent7-Feb-11 22:42 
AnswerRe: my mysql database string connection Pin
OriginalGriff7-Feb-11 23:07
mveOriginalGriff7-Feb-11 23:07 
AnswerAttempt to bump post Pin
Pete O'Hanlon7-Feb-11 23:48
mvePete O'Hanlon7-Feb-11 23:48 
AnswerRe: my mysql database string connection Pin
RaviRanjanKr9-Feb-11 15:29
professionalRaviRanjanKr9-Feb-11 15:29 
QuestionHow to store text files for better reading and lesser disk space Pin
Anurag Gandhi7-Feb-11 21:58
professionalAnurag Gandhi7-Feb-11 21:58 

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.