Click here to Skip to main content
15,887,821 members
Home / Discussions / C#
   

C#

 
AnswerRe: I add table into Control dataSet of XtraReport ? Pin
Marco Bertschi3-May-16 21:30
protectorMarco Bertschi3-May-16 21:30 
Questionwhat do you know the name of this control ? Pin
Member 245846728-Apr-16 20:37
Member 245846728-Apr-16 20:37 
AnswerRe: what do you know the name of this control ? Pin
Pete O'Hanlon28-Apr-16 23:42
mvePete O'Hanlon28-Apr-16 23:42 
QuestionSerializing a ResourceDictionary to binary and back Pin
Imagiv28-Apr-16 8:25
Imagiv28-Apr-16 8:25 
AnswerRe: Serializing a ResourceDictionary to binary and back Pin
Matt T Heffron28-Apr-16 14:48
professionalMatt T Heffron28-Apr-16 14:48 
GeneralRe: Serializing a ResourceDictionary to binary and back Pin
Imagiv28-Apr-16 15:39
Imagiv28-Apr-16 15:39 
QuestionIs it possible to read all probe response coming to a certain access point Pin
mohammed qaid28-Apr-16 7:31
mohammed qaid28-Apr-16 7:31 
Question[SOLVED] Drag and drop file explorer Pin
AndrewRue28-Apr-16 2:47
professionalAndrewRue28-Apr-16 2:47 
Hello

I'd like to do a file explorer. With the Microsoft tutorial i created a form with two treeviews and two listboxes. Now i want to copy files be drag and drop from one to the other listbox. liw_Source is my first Listbox. Here i want to select the files and drag it to liw_Target. In liw_Target there should the files be pasted.

The File is shown in the secont Listbox. But restarting the application, the file isn't copied. How do i copy the file?

My code:
C#
private void liw_Source_ItemDrag(object sender, ItemDragEventArgs e)
{
    string s = e.Item.ToString();
    DoDragDrop(s, DragDropEffects.Copy | DragDropEffects.Move);
}

private void liw_Target_DragEnter(object sender, DragEventArgs e)
{

if (e.Data.GetDataPresent(DataFormats.Text))
    e.Effect = DragDropEffects.Copy;
else
    e.Effect = DragDropEffects.None;
}

private void liw_Target_DragDrop(object sender, DragEventArgs e)
{
    string typestring = "Type";
string s = e.Data.GetData(typestring.GetType()).ToString();
string orig_string = s;
s = s.Substring(s.IndexOf(":") + 1).Trim();
s = s.Substring(1, s.Length - 2);

this.liw_Target.Items.Add(s);

IEnumerator enumerator = liw_Source.Items.GetEnumerator();
int whichIdx = -1;
int idx = 0;
while (enumerator.MoveNext()) {
    string s2 = enumerator.Current.ToString();
    if (s2.Equals(orig_string)) {
        whichIdx = idx;
        break;
    }
    idx++;
}
this.liw_Source.Items.RemoveAt(whichIdx);

}


Thanks for your Help.

modified 29-Apr-16 3:27am.

AnswerRe: Drag and drop file explorer Pin
OriginalGriff28-Apr-16 3:02
mveOriginalGriff28-Apr-16 3:02 
GeneralRe: Drag and drop file explorer Pin
AndrewRue28-Apr-16 3:11
professionalAndrewRue28-Apr-16 3:11 
GeneralRe: Drag and drop file explorer Pin
OriginalGriff28-Apr-16 3:26
mveOriginalGriff28-Apr-16 3:26 
GeneralRe: Drag and drop file explorer Pin
AndrewRue28-Apr-16 19:50
professionalAndrewRue28-Apr-16 19:50 
GeneralRe: Drag and drop file explorer Pin
OriginalGriff28-Apr-16 20:54
mveOriginalGriff28-Apr-16 20:54 
GeneralRe: Drag and drop file explorer Pin
AndrewRue28-Apr-16 21:27
professionalAndrewRue28-Apr-16 21:27 
GeneralRe: Drag and drop file explorer Pin
OriginalGriff28-Apr-16 22:44
mveOriginalGriff28-Apr-16 22:44 
QuestionShouldnt this work? Pin
David Reeves27-Apr-16 12:25
David Reeves27-Apr-16 12:25 
AnswerRe: Shouldnt this work? Pin
Dave Kreskowiak27-Apr-16 13:54
mveDave Kreskowiak27-Apr-16 13:54 
AnswerRe: Shouldnt this work? Pin
Brisingr Aerowing27-Apr-16 14:21
professionalBrisingr Aerowing27-Apr-16 14:21 
GeneralRe: Shouldnt this work? Pin
David Reeves27-Apr-16 14:40
David Reeves27-Apr-16 14:40 
GeneralRe: Shouldnt this work? Pin
Philippe Mori27-Apr-16 15:57
Philippe Mori27-Apr-16 15:57 
GeneralRe: Shouldnt this work? Pin
Sascha Lefèvre27-Apr-16 21:27
professionalSascha Lefèvre27-Apr-16 21:27 
GeneralRe: Shouldnt this work? Pin
David Reeves28-Apr-16 1:18
David Reeves28-Apr-16 1:18 
QuestionUsing a scripting language in a C# exe Pin
Foothill27-Apr-16 8:37
professionalFoothill27-Apr-16 8:37 
AnswerRe: Using a scripting language in a C# exe Pin
Pete O'Hanlon27-Apr-16 9:22
mvePete O'Hanlon27-Apr-16 9:22 
GeneralRe: Using a scripting language in a C# exe Pin
Foothill27-Apr-16 9:41
professionalFoothill27-Apr-16 9:41 

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.