DataSet dataSetMachine = new DataSet();
dataSetMachine = new MachineSystem().GetDataMachineStatusperCompanyPlantSectionLine(3100,3110,"A","");
DataTable tabelMachine= new DataTable();
tabelMachine = dataSetMachine.Tables[0];
foreach (DataRow drMachine in tabelMachine.Rows)
{
string machineId = drMachine["MachineId"].ToString();
string status = drMachine["Status"].ToString();
int sts = Convert.ToInt32(status);
DataGridViewCell cell = repeaterMachineDasboard.Rows[e.RowIndex].Cells[e.ColumnIndex];
if ((string)cell.Value == machineId && sts == 4) // mesin bagus
{
//e.CellStyle.BackColor = Color.Red;
repeaterMachineDasboard.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.LightGreen;
}
else if ((string)cell.Value == machineId && sts == 3) // mesin sedang diperbaiki
{
//e.CellStyle.BackColor = Color.Red;
repeaterMachineDasboard.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.Orange;
}
else if ((string)cell.Value == machineId && sts == 2) // mesin baru diketahui rusak
{
//e.CellStyle.BackColor = Color.Red;
repeaterMachineDasboard.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.Yellow;
}
else if ((string)cell.Value == machineId && sts == 1) // mesin bermasalah atau rusak
{
//e.CellStyle.BackColor = Color.Red;
repeaterMachineDasboard.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.Red;
}
}
Tuesday, 13 September 2016
Tuesday, 6 September 2016
Solve combobox return object
Selama ini selected value yang aku gunakan di combobox selalu return object, dan hal itu ternyata disebabkan oleh menempatan display member dan value member setelah datasource,
jadi seharusnya set display member, value member baru kemudian datasource.
http://stackoverflow.com/questions/26870157/combobox-selectedvalue-returning-an-object-and-not-the-value
jadi seharusnya set display member, value member baru kemudian datasource.
http://stackoverflow.com/questions/26870157/combobox-selectedvalue-returning-an-object-and-not-the-value
Monday, 5 September 2016
c# - DataGridView - Use DataPropertyName to show child element property
class MyClass
{
public int Id;
public MyOtherClass OtherClass;
}
class MyOtherClass
{
public string Name;
public int Number;
}
This code help me....
private void dgv_CellFormatting( object sender, DataGridViewCellFormattingEventArgs e )
{
MyClass data = dgv.Rows[ e.RowIndex ].DataBoundItem as MyClass;
dgv.Rows[ e.RowIndex ].Cells[ "colName" ].Value = data.OtherClass.Name;
dgv.Rows[ e.RowIndex ].Cells[ "colNumber" ].Value = data.OtherClass.Number;
}
Subscribe to:
Posts (Atom)