private void UpdateGridview() { std st = new std(); DataTable dt = new DataTable(); if (checkBox1.Checked) { dt = st.SelectForSMStavalod(); } else { dt = st.SelectTavalod(); } txttedadegirandeha.Text = "0"; dataGridView1.DataSource = dt; dataGridView1.AutoGenerateColumns = true; dtforprint = st.Select(); //if (dataGridView1.RowCount == 0) //{ // cmddel.Enabled = false; // cmdedit.Enabled = false; //} string[] col_headers = { "تیک ارسال", "شماره", "نام و نام خانوادگی", "تلفن همراه", "تاریخ تولد" }; //int[] col_width = { 25, 50, 80, 130, 80, 90, 80, 80, 80, 80, 80, 120, 95 }; for (int i = 0; i < col_headers.Length; i++) { dataGridView1.Columns[i].HeaderText = col_headers[i].ToString(); // dataGridView1.Columns[i].Width = col_width[i]; } dataGridView1.Columns["stdno"].Visible = false; DataGridViewCellStyle objAlternatingCellStyle = new DataGridViewCellStyle(); objAlternatingCellStyle.BackColor = Color.Khaki; dataGridView1.AlternatingRowsDefaultCellStyle = objAlternatingCellStyle; DataGridViewCellStyle objAlternatingCellStyle1 = new DataGridViewCellStyle(); objAlternatingCellStyle1.BackColor = Color.LightBlue; dataGridView1.Columns["mob"].DefaultCellStyle = objAlternatingCellStyle1; // dataGridView1.Columns["tel"].DefaultCellStyle = objAlternatingCellStyle1; }