Im trying to change a Combobox value which is inside a Datagridview. The data that comes into the datagriview comes from a XML file which is placed in a Dataset. So basically I want to get the data set into the DataGridView. The second column should be a ComboBox. I read on the forum I should make a dictionary for the Combobox so I started with that but now how to continue I'm not really sure. Here is some code I have allready. These are the two classes I have in a dedicated class that I made. Now in my
public class ClassMAVLinkCmd
{
Dictionary<int, MVLCmdMessage> MAVLnkCommand = new Dictionary<int, MVLCmdMessage>()
{
{16, new MVLCmdMessage {UAVCANMode = "UAV_CMD", MAVLinkCommand = "MAV_CMD_NAV_WAYPOINT", MAVLinkMsgId = 16} } ,
{17, new MVLCmdMessage {UAVCANMode = "UAV_CMD", MAVLinkCommand = "MAV_CMD_NAV_LOITER_UNLIM", MAVLinkMsgId = 17} },
{18, new MVLCmdMessage {UAVCANMode = "UAV_CMD", MAVLinkCommand = "MAV_CMD_NAV_LOITER_TURNS", MAVLinkMsgId = 18} },
};
}
public class MVLCmdMessage
{
public string UAVCANMode { get; set; }
public string MAVLinkCommand { get; set; }
public int MAVLinkMsgId { get; set; }
}
Now when I press the button to read the file and load it into the DataGridview I have this so far:
private void btnLoad_Click(object sender, EventArgs e)
{
DataSet dsRoute = new DataSet();
//Open the file dialog and select a XML file
if (myOpen.ShowDialog() == DialogResult.OK)
{
try
{
if ((myStream = myOpen.OpenFile()) != null)
{
using (myStream)
dsRoute.ReadXml(myStream);
strFilename = myOpen.SafeFileName.ToString();
StatusRouteName.Text = strFilename;
int i = 0;
int length = dsRoute.Tables.Count;
for (i = 0; i < length; i++)
{
DataWayPoints.Rows.Add();
int row = WayPointList.Count;
DataWayPoints["Waypoint", i].Value = Convert.ToString(i + 1);
//DataWayPoints["MAVLnkCmd", i].Value = dsRoute.Tables[i].Rows[0]["MAVLnkCmd"].ToString();
//Need to investigate how to set a cmbBox in a DGV!!!!!!!!!!!!!!!!!!!!!!
DataWayPoints["P1", i].Value = dsRoute.Tables[i].Rows[0]["P1"].ToString();
DataWayPoints["P2", i].Value = dsRoute.Tables[i].Rows[0]["P2"].ToString();
DataWayPoints["P3", i].Value = dsRoute.Tables[i].Rows[0]["P3"].ToString();
DataWayPoints["P4", i].Value = dsRoute.Tables[i].Rows[0]["P4"].ToString();
DataWayPoints["Latitude", i].Value = dsRoute.Tables[i].Rows[0]["Latitude"].ToString();
DataWayPoints["Longitude", i].Value = dsRoute.Tables[i].Rows[0]["Longitude"].ToString();
DataWayPoints["Altitude", i].Value = dsRoute.Tables[i].Rows[0]["Altitude"].ToString();
DataWayPoints["DistanceToNextWpt", i].Value = dsRoute.Tables[i].Rows[0]["DistanceToNextWpt"].ToString();
DataWayPoints["Velocity", i].Value = dsRoute.Tables[i].Rows[0]["Velocity"].ToString();
}
lblWayPointTotal.Text = "Waypoint total: " + length.ToString();
CalcWptDistances();
}
}
catch (Exception )
{
MessageBox.Show("Error could not open the selected file");
}
UpdateRouteList();
}
}
Could anybody explain me what would be the next step, thanks a lot in advance