// display history of cost private void DisplayHistoryOfCost(long id) { string start_day = string.Empty; string end_day = string.Empty; dataGridView1.AutoGenerateColumns = true; string items = string.Empty; try { dataGridView1.MultiSelect = false; dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridView1.AllowUserToResizeRows = false; // get datatable of data grid view Access access = new Access(); System.Data.DataTable table = access.getCostList(id); Cost cost = new Cost(table.Rows[0]); } catch (Exception ex) { MessageBox.Show(ex.Message); } }