Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8148967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:45:13+00:00 2026-06-06T14:45:13+00:00

I have created a binded DataGridView that has one single column. I want to

  • 0

I have created a binded DataGridView that has one single column. I want to be able to drag and drop files onto the DataGridView and store only the filenames (Path and Name) into the cells of the column. I have been doing research and the way to do it is to use the events DragDrop and DragEnter and have tried a couple different things but none have worked. Does anyone know how to do this?

My code:

   private void PlaylistDataGridDragEnter(object sender, DragEventArgs e)
    {
        if (e.Data.GetDataPresent(DataFormats.FileDrop))
            e.Effect = DragDropEffects.All;
        else
            e.Effect = DragDropEffects.None;
    }

    private void PlaylistDataGridDragDrop(object sender, DragEventArgs e)
    {      
        if (e.Data.GetDataPresent(DataFormats.FileDrop))
        {
            var files = (string[])e.Data.GetData(DataFormats.FileDrop);
            foreach (var filePath in files)
            {
                var a = (DataRowView) PlaylistBindingSource.AddNew();
                a.BeginEdit();
                a[0] = filePath;
                a.EndEdit();
            }
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:45:14+00:00Added an answer on June 6, 2026 at 2:45 pm

    You’ll need to implement the DragEnter and DragDrop events like you say. Here is a good article on how to do this. You added your code as I was typing. You just need to adjust how you add items to your DataGridView. You need to add a new row and then address the last row:

    PlaylistDataGrid.Rows.Add();
    PlayListDataGrid[0,PlaylistDataGrid.RowCount-1].Value = filePath
    

    This assumes you want to put the data in the first column of the DataGridView.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created 2 dropdownlists that are binded to a SQL DB and then
I have a CFWINDOW which displays multiple drop downs that are binded to respective
I have a Gridview which is binded to a datatable that I created. The
I have created custom listview in that have list of textview & list of
I have created a custom JTree. That tree could be filtered to show only
I have created a new Bitmap object and now want do draw some text
I have created a png image in photoshop with transparencies that I have loaded
I have created some aidl files for IPC in my Android project. They compile
I am using MVVM Light. I have created a window that looks like this:
I have created a custom Model Binder that inherits from DefaultModelBinder, and overriding the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.