0

我打算用 Telerik 桌面控件制作一个桌面应用程序。我的主要表单代码是:

 public partial class MainForm3 : Telerik.WinControls.UI.RadForm
       {
        private string ISadmin = string.Empty;
        private string Customer_ID = string.Empty;
        private string sLanguage_Code = "en-US";
        private string Contact_ID = string.Empty;
        public MainForm3(string Contact_IDa, string Customer_IDa, string ISadmina)
        {
            InitializeComponent();

            this.Contact_ID = Contact_IDa;
            this.Customer_ID = Customer_IDa;
            this.ISadmin = ISadmina;  
        }
        private void MainForm3_Load(object sender, EventArgs e)
                {
                    this.IsMdiContainer = true;
                    this.radDock1.AutoDetectMdiChildren = true;
                }
        private void radMenuItem1_Click(object sender, EventArgs e)
        {
            FormThree formthree= new FormThree ();
            formthree.MdiParent = this;
            formthree.Show();
        }

    }

字符串 Contact_IDa、字符串 Customer_IDa、字符串 ISadmina 来自登录页面

登录页面代码:

if(login success){

//setup necessary values 



 System.Threading.Thread t = new System.Threading.Thread(new  System.Threading.ThreadStart(ThreadProc));
 t.Start();
 this.Close();

}

public void ThreadProc()
        {
            Application.Run(new MainForm3(Contact_ID, Customer_ID, IsAdmin));
        }

和 FormThree 代码是;

public partial class FormThree : Telerik.WinControls.UI.RadForm
           {
        public FormThree ()
        {
            InitializeComponent(); 
            splitPanel1.AllowDrop = true;
            splitPanel1.DragEnter += splitPanel1_DragEnter;
            splitPanel1.DragDrop += splitPanel1_DragDrop;
        }
        private void splitPanel1_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] filePaths = (string[])(e.Data.GetData(DataFormats.FileDrop));

                foreach (string fileLoc in filePaths)
                {
                    // Code to read the contents of the text file
                    if (File.Exists(fileLoc))
                    {
                        using (TextReader tr = new StreamReader(fileLoc))
                        {
                            string Name = Path.GetFileName(fileLoc);
                            string extention = Path.GetExtension(fileLoc);
                            MessageBox.Show("Name:" + Name + " </br>Extention:" + extention);
                            //MessageBox.Show(tr.ReadToEnd());
                        }
                    }
                }
            }
        }

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

        private void FormThree_Load(object sender, EventArgs e)
        {
        }
    }

现在的问题是当我单击“radMenuItem1”加载我的表单 FormThree 时,它​​说“DragDrop 注册没有成功”。为什么以及如何解决这个问题.....

4

1 回答 1

0

在每个应用程序启动时启动您的应用程序。
在您的 Main 方法中执行以下操作:

Application.Run(new MainForm3()); 

构造函数中没有参数,然后在您的 MainForm3 构造函数中(在 InitializeComponent 之前)进行登录,打开一个专用的模式表单以获取继续所需的登录凭据。

如果登录失败,您可以通知用户并使用 Application.Exit() 关闭应用程序。如果登录成功,则读取 MainForm3 所需的值。无需启动不同的线程

于 2012-04-07T13:11:41.280 回答