private void PopulateCallLog() { dgvCallLog.Rows.Clear(); DataTable call_data; if (string.IsNullOrEmpty(cbSearch.Text)) { call_data = CallLog.GetCallLog((int)ndDisplayCount.Value); } else { call_data = CallLog.FilterCallLog(cbSearch.Text, (int)ndDisplayCount.Value); } foreach (DataRow call in call_data.Rows) { DateTime the_date = Common.GetDateTimeFromSQLiteDate(call["time"].ToString()); dgvCallLog.Rows.Add(); string name_str = call["name"].ToString(); dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].Cells[DGV_LOG_NAME].Value = Common.GetUnsafeSqlString(name_str); dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].Cells[DGV_LOG_NUMBER].Value = call["number"].ToString(); dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].Cells[DGV_LOG_DATE].Value = GetDateTimeWithoutSeconds(the_date); dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].Cells[DGV_LOG_DUR].Value = Common.ConvertDurationToTime(int.Parse(call["dur"].ToString())); dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].Cells[DGV_LOG_LINE].Value = call["line"].ToString(); dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].Cells[DGV_LOG_IO].Value = call["io"].ToString(); dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].DefaultCellStyle.ForeColor = call["io"].ToString() == "I" ? Program.C_INCOMING_CALL_FOREGROUND : Program.C_OUTGOING_CALL_FOREGROUND; dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].Cells[DGV_LOG_RINGS].Value = call["rings"].ToString(); dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].Cells[DGV_LOG_SORT_DATE].Value = the_date; dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].Cells[DGV_LOG_ID].Value = call["uid"].ToString(); dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].Cells[DGV_LOG_CK].Value = call["ck"]; } dgvCallLog.ClearSelection(); }