Практическое руководство автоматическое изменение страницы с 10 сек интервалом обязанности и достижения
мне нужна подкачка winform datagrid с интервалом таймера,
Пожалуйста, помогите мне
Что я уже пробовал:
private void BindGrid(int pageIndex) { using (SqlConnection con = new SqlConnection(connection)) { using (SqlCommand cmd = new SqlCommand("Employee_Details_procedure", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PageIndex", pageIndex); cmd.Parameters.AddWithValue("@PageSize", PageSize); cmd.Parameters.Add("@RecordCount", SqlDbType.Int, 2); cmd.Parameters["@RecordCount"].Direction = ParameterDirection.Output; con.Open(); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); dataGridView1.AutoGenerateColumns = false; dataGridView1.Columns[0].Name = "image"; dataGridView1.Columns[0].HeaderText = "Image"; dataGridView1.Columns[0].DataPropertyName = "Image"; dataGridView1.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView1.Columns[1].Name = "id"; dataGridView1.Columns[1].HeaderText = "Id"; dataGridView1.Columns[1].DataPropertyName = "id"; dataGridView1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView1.Columns[2].Name = "name"; dataGridView1.Columns[2].HeaderText = "Name"; dataGridView1.Columns[2].DataPropertyName = "name"; dataGridView1.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dataGridView1.Columns[3].Name = "designation"; dataGridView1.Columns[3].HeaderText = "Designation"; dataGridView1.Columns[3].DataPropertyName = "designation"; dataGridView1.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dataGridView1.Columns[4].Name = "address"; dataGridView1.Columns[4].HeaderText = "Address"; dataGridView1.Columns[4].DataPropertyName = "address"; dataGridView1.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dataGridView1.AllowUserToAddRows = false; dataGridView1.DataSource = dt; con.Close(); int recordCount = Convert.ToInt32(cmd.Parameters["@RecordCount"].Value); this.PopulatePager(recordCount, pageIndex); } } int pageCount = 0; List<page> pages_list = new List<page>(); private void PopulatePager(int recordCount, int currentPage) {if (count == 0) { count = 2; } else { count = count + 1; } Timer.Tick += new System.EventHandler(this.Timer_Tick); Timer.Interval = 2000; Timer.Start(); } //string Name; System.Timers.Timer timer = new System.Timers.Timer(); public void MyElapsedMethod(object sender, ElapsedEventArgs e, string Name) { BindGrid(int.Parse( Name.ToString())); } private void Timer_Tick(object sender, EventArgs e) { this.BindGrid(3); // System.Threading.Thread.Sleep(8000); } }
Maciej Los
"Я хочу...- это не похоже на вопрос.
Управление Datagrid недоступно в WinForm.