private void FillDataSetAndView() { // Initialize a new instance of the DataSet object... contact cl = new contact(); datat = cl.Select(); // Set our CurrencyManager object // to the DataView object... objCurrencyManager = (CurrencyManager)(this.BindingContext[datat]); }
public void UpdateGridview() { contact st = new contact(); DataTable dt, dt2 = new DataTable(); dt = st.SelectForSMS(); 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 = { "تیک ارسال", "شماره", "نام و نام خانوادگی", "تلفن همراه 1", "تلفن همراه 2" }; //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[1].Visible = false; DataGridViewCellStyle objAlternatingCellStyle = new DataGridViewCellStyle(); objAlternatingCellStyle.BackColor = Color.Khaki; dataGridView1.AlternatingRowsDefaultCellStyle = objAlternatingCellStyle; DataGridViewCellStyle objAlternatingCellStyle1 = new DataGridViewCellStyle(); objAlternatingCellStyle1.BackColor = Color.LightBlue; dataGridView1.Columns[3].DefaultCellStyle = objAlternatingCellStyle1; // dataGridView1.Columns["tel"].DefaultCellStyle = objAlternatingCellStyle1; }