private void LoadData() { var select = "SELECT * FROM [dbo].[user]"; var ds = v.load_data(select); dataGridView1.ReadOnly = true; dataGridView1.DataSource = ds.Tables[0]; dataGridView1.Columns["Id"].Visible = false; dataGridView1.Columns["occupation"].Visible = false; dataGridView1.Columns["gurdian"].Visible = false; dataGridView1.Columns["father_name"].Visible = false; dataGridView1.Columns["father_occupation"].Visible = false; dataGridView1.Columns["official_address"].Visible = false; dataGridView1.Columns["tel_no"].Visible = false; dataGridView1.Columns["photo"].Visible = false; dataGridView1.Columns["name"].HeaderText = "Name"; dataGridView1.Columns["doj"].HeaderText = "Join Date"; dataGridView1.Columns["doj"].DefaultCellStyle.Format = "dd-MM-yyyy"; dataGridView1.Columns["address"].HeaderText = "Address"; dataGridView1.Columns["mobile"].HeaderText = "Mobile"; dataGridView1.Columns["b_group"].HeaderText = "Blood Group"; dataGridView1.Columns["dob"].HeaderText = "Birthdate"; dataGridView1.Columns["dob"].DefaultCellStyle.Format = "dd-MM-yyyy"; dataGridView1.Columns["address"].SortMode = DataGridViewColumnSortMode.NotSortable; dataGridView1.Columns["mobile"].SortMode = DataGridViewColumnSortMode.NotSortable; dataGridView1.Columns["b_group"].SortMode = DataGridViewColumnSortMode.NotSortable; // con.Open(); // SqlDataAdapter adpa = new SqlDataAdapter("SELECT * FROM [dbo].[user]", con); // DataSet ds = new System.Data.DataSet(); // adpa.Fill(ds, "user"); // dataGridView1.DataSource = ds.Tables[0]; //dataGridView1.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.EnableResizing; //or even better .DisableResizing. Most time consumption enum is DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders //// set it to false if not needed //dataGridView1.RowHeadersVisible = false; //con.Close(); }
private void manageFees_Load(object sender, EventArgs e) { viewClass v = new viewClass(); DataSet ds = v.load_data("SELECT Id,name from [dbo].[user]"); if (ds.Tables[0].Rows.Count > 0) { user_id.DataSource = ds.Tables[0]; user_id.DisplayMember = "name"; user_id.ValueMember = "Id"; } }
public void Load_data(string select) { try { viewClass v = new viewClass(); DataSet ds = v.load_data(select); dataGridView1.ReadOnly = true; dataGridView1.DataSource = ds.Tables[0]; dataGridView1.Columns["amount"].HeaderText = "Amount"; dataGridView1.Columns["fees_date"].HeaderText = "Paid Date"; dataGridView1.Columns["expire_date"].HeaderText = "Expires Date"; dataGridView1.Columns["validity"].HeaderText = "Validity"; dataGridView1.Columns["mobile"].HeaderText = "Mobile"; dataGridView1.Columns["name"].HeaderText = "Name"; } catch { } }