【问题标题】:How to check whether it .mdb file format dragged in WinForms?如何检查WinForms中是否拖入了.mdb文件格式?
【发布时间】:2012-11-22 23:06:22
【问题描述】:

我尝试下一个方法:

this.AllowDrop = true;
this.DragEnter += new System.Windows.Forms.DragEventHandler(Form_DragEnter);

void Form_DragEnter(object sender, DragEventArgs e)
{
     // here I need to check whether it access .mdb format
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
     {
         e.Effect = DragDropEffects.Copy;
     }
     else
     {
         e.Effect = DragDropEffects.None;
     }
 }

如何检查呢?在DataFormats. 中没有数据库格式

【问题讨论】:

    标签: c# winforms drag-and-drop


    【解决方案1】:
    string[] FileList;
    
    if (e.Data.GetDataPresent(DataFormats.FileDrop))
    {
        FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false);
    }
    else if (e.Data.GetDataPresent(DataFormats.StringFormat))
    {
        FileList = new string[] {e.Data.GetData(DataFormats.StringFormat, false).ToString()};
    }
    else
    {
        return;
    }
    

    然后循环遍历字符串数组checking file extensions

    【讨论】:

      猜你喜欢
      • 2015-11-17
      • 1970-01-01
      • 2022-12-21
      • 2018-06-27
      • 2013-12-29
      • 2020-07-01
      • 1970-01-01
      • 2012-08-22
      • 1970-01-01
      相关资源
      最近更新 更多