I have a winForm application that connects to a MS Access database. When i load the table in a datgridview i want to be able to populate a checkbox value that's in my WinForm application based on whether the same checkbox is selected or not selected in my database. In other words after my table is loaded when i click on a record the value of the check box will changed based on whether it is checked or unchecked in the database. I am doing the same thing with textboxes & combo boxes but i am unsure how to do it with the checkboxes. Here is my code:
private void dataGridViewWendys_CellContentClick(object sender, DataGridViewCellEventArgs e)//Start of code for Wendys DataGridView Cell Content
{
if(e.RowIndex>=0)
{
DataGridViewRow row = dataGridViewWendys.Rows[e.RowIndex];
txt_ID.Text = row.Cells["ID"].Value.ToString();
txt_Nickname.Text = row.Cells["Nickname"].Value.ToString();
txt_ProjNumber.Text = row.Cells["ProjectNumber"].Value.ToString();
txt_ProjYear.Text = row.Cells["ProjectYear"].Value.ToString();
txt_StoreNumber.Text = row.Cells["StoreNumber"].Value.ToString();
txt_StreetAddress.Text = row.Cells["StreetAddress"].Value.ToString();
txt_city.Text = row.Cells["City"].Value.ToString();
cb_State.Text = row.Cells["State"].Value.ToString();
txt_ZipCode.Text = row.Cells["Zipcode"].Value.ToString();
cb_AssetType.Text = row.Cells["AssetType"].Value.ToString();
cb_BaseModel.Text = row.Cells["BaseModel"].Value.ToString();
cb_BldgPrototypeYear.Text = row.Cells["BldgPrototypeYear"].Value.ToString();
cb_UpgradeClass.Text = row.Cells["UpgradeClass"].Value.ToString();
cb_ExtWallStructure.Text = row.Cells["ExtWallStructure"].Value.ToString();
cb_NewWallStructure.Text = row.Cells["NewWallStructure"].Value.ToString();
ckb_StructDwgs.Checked = row.Cells["StructuralDwgs"].Value;
cb_BladeDesign.Text = row.Cells["BladeDesign"].Value.ToString();
//ckb_CurtainWall.Checked = row.Cells["CurtainWall"].Value.ToString();
//Corragated Metal Above Windows.c = row.Cells["CorrugatedMlFrt"].Value.ToString();
cb_Addition.Text = row.Cells["Addition"].Value.ToString();
//ckb_SecondPUW.Checked = row.Cells["SecondPUW"].Value.ToString();
//ckb_PUWExtention.checked = row.Cells["PUWWindowExtention"].Value.ToString();
cb_ExtFndType.Text = row.Cells["ExstFoundationType"].Value.ToString();
cb_NewFndType.Text = row.Cells["NewFoundationType"].Value.ToString();
//ckb_PUWVestibule.Checked = row.Cells["PUWVestibule"].Value.ToString();
//ckb_NonPUWVestibule.Checked = row.Cells["NonPUWVestibule"].Value.ToString();
cb_DriveThruType.Text = row.Cells["DriveThruType"].Value.ToString();
cb_TrashEnclosure.Text = row.Cells["TrashEnclosure"].Value.ToString();
cb_MenuboardType.Text = row.Cells["DigitalStatic"].Value.ToString();
cb_Patio.Text = row.Cells["Patio"].Value.ToString();
//ckb_ExtTrayWash.Checked = row.Cells["ExtgTrayWash"].Value.ToString();
cb_SelfServe.Text = row.Cells["SelfServe"].Value.ToString();
//ckb_SpandrelGlass.Checked = row.Cells["SpandrelGlass"].Value.ToString();
cb_CounterStyle.Text = row.Cells["CounterStyle"].Value.ToString();
cb_RaisedCeiling.Text = row.Cells["RaisedCeiling"].Value.ToString();
//ckb_KitchenWork.Checked = row.Cells["KitchenWork"].Value.ToString();
//ckb_ElecGasHeat.Checked = row.Cells["ElecGasHeat"].Value.ToString();
//ckb_ElecGasfryer.Checked = row.Cells["ElecGasFryers"].Value.ToString();
//ckb_ElecGasGrille.Checked = row.Cells["ElecGasGrilles"].Value.ToString();
//ckbBlockBands.Checked = row.Cells["BlockBands"].Value.ToString();
list_Notes.Text = row.Cells["Notes"].Value.ToString();
cb_ExtRoofStructure.Text = row.Cells["ExtRoofStructure"].Value.ToString();
cb_NewRoofStructure.Text = row.Cells["NewRoofStructure"].Value.ToString();
Aucun commentaire:
Enregistrer un commentaire