我打算用 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 注册没有成功”。为什么以及如何解决这个问题.....