Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello friends,

I have 3 questions about ComboBox, anyone can help me, please? :)

 

1. Although I have enabled AllowDrop property of ComboBox it does not allow me to drag and drop files into ComboBox. Why?

 

2. Then should I process incoming files in the _DragDrop event, yes?

 

3. How can I get the Files.Count to get the number of dropped files?

 

Thank you very much for helping me :)

  • Administrators
Posted

       private void comboBox1_DragDrop(object sender, DragEventArgs e)
       {
         string[] names = (string[]) e.Data.GetData(DataFormats.FileDrop);

           comboBox1.Items.AddRange(names);
       }

       private void comboBox1_DragEnter(object sender, DragEventArgs e)
       {
           if(e.Data.GetDataPresent(DataFormats.FileDrop))
            e.Effect = DragDropEffects.Copy;
       }

Should give you the basic idea, the key is to handle the DragEnter and state what effect should be displayed, if this step is missed then the drop event will never be fired.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...