有人可以帮我解决这个问题,我不知道我应该做什么。
这是错误:
错误 1 无法将类型“object”隐式转换为“Flashloader.Controller”。存在显式转换(您是否缺少演员表?)
这是我的来源:
public partial class NewApplication : Form
{
private toepassinginifile _toepassinginifile;
private controllerinifile _controllerinifile;
//private controllerinifile _controlIniFile;
public Toepassing toepassing = new Toepassing();
public NewApplication( toepassinginifile iniFile)
{
_toepassinginifile = iniFile;
_controllerinifile = new controllerinifile();
controllerComboBox.DataSource = _controllerinifile.Controllers;
InitializeComponent();
}
private void button4_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "Srec Files (.a20; .a21; .a26; .a44)|*.a20; *.a21; *.a26; *.a44|All files (*.*)|*.*";
openFileDialog1.Title = ("Choose a file");
openFileDialog1.InitialDirectory = Path.Combine(Directory.GetCurrentDirectory());
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
fileBox.Text = (System.IO.Path.GetFileName(openFileDialog1.FileName));
}
}
private void button3_Click(object sender, EventArgs e)
{
toepassing.Name = nameBox.Text;
---->#toepassing.Controller = controllerComboBox.SelectedItem;#
toepassing.TabTip = descBox.Text;
toepassing.Lastfile = openFileDialog1.FileName;
fileBox.Text = openFileDialog1.FileName;
if (nameBox.Text == "")
MessageBox.Show("You haven't assigned a Name");
else if (controllerComboBox.Text == "")
MessageBox.Show("You haven't assigned a Controller");
else if (descBox.Text == "")
MessageBox.Show("You haven't assigned a Desciption");
else if (fileBox.Text == "")
MessageBox.Show("You haven't assigned a Applicationfile");
_toepassinginifile.ToePassingen.Add(toepassing);
_toepassinginifile.Save();
MessageBox.Show("Save Succesfull");
this.Close();
}
}
如何解决这个问题,找不到问题,因为我想将我的组合框连接到我的 ini 文件和我已经拥有的功能,但在某种程度上我得到了这个错误。