private void ResaultList_SelectedIndexChanged(object sender, EventArgs e) { MainForm f1 = new MainForm(); if(f1.GetValue("\\d+",RowsPerPageTextBox.Text).Length>0) RowsPerPage = Convert.ToInt32(f1.GetValue("\\d+",RowsPerPageTextBox.Text)); dataGridView1.Columns.Clear(); dataGridView1.Rows.Clear(); if (ResaultDataSet[ResaultList.SelectedIndex].Tables.Count > 0) { foreach (DataColumn dc in ResaultDataSet[ResaultList.SelectedIndex].Tables[0].Columns) { dataGridView1.Columns.Add(dc.ColumnName.ToString(), dc.ColumnName.ToString()); } if (ResaultDataSet[ResaultList.SelectedIndex].Tables[0].Rows.Count > 0) { if (ResaultDataSet[ResaultList.SelectedIndex].Tables[0].Rows.Count > RowsPerPage) { PageList.Items.Clear(); GetPage(ResaultList.SelectedIndex); PageList.SelectedItem = PageList.Items[0]; PageList.Enabled = true; } else { foreach (DataRow dr in ResaultDataSet[ResaultList.SelectedIndex].Tables[0].Rows) { object[] dtrow = new object[dr.Table.Columns.Count]; for (int ii = 0; ii < dr.Table.Columns.Count; ii++) { if (dr[ii] == DBNull.Value) { dtrow[ii] = "null"; } else { dtrow[ii] = dr[ii].ToString(); } } dataGridView1.Rows.Add(dtrow); } BackBtn.Enabled = false; NextBtn.Enabled = false; PageList.Enabled = false; } } else { dataGridView1.Rows.Add("没有记录。"); } ResaultStatLabel.Text = "返回" + ResaultDataSet[ResaultList.SelectedIndex].Tables[0].Columns.Count.ToString() + "列" + ResaultDataSet[ResaultList.SelectedIndex].Tables[0].Rows.Count.ToString() + "行数据。"; } else { dataGridView1.Columns.Add("column1", string.Empty); dataGridView1.Rows.Add("没有返回数据。"); } }
private void RowsPerPageTextBox_TextChanged(object sender, EventArgs e) { MainForm f1 = new MainForm(); if (f1.GetValue("\\d+", RowsPerPageTextBox.Text).Length > 0) { if (Convert.ToInt32(f1.GetValue("\\d+", RowsPerPageTextBox.Text)) > 1000) toolTip1.Show("每页显示数量过多容易导致程序无响应,建议不要超过500", this, RowsPerPageTextBox.Location.X, RowsPerPageTextBox.Location.Y + RowsPerPageTextBox.Height+30); } }
private void SearchBtn_Click(object sender, EventArgs e) { MainForm f1 = new MainForm(); if (f1.GetValue("\\d+", RowsPerPageTextBox.Text).Length > 0) RowsPerPage = Convert.ToInt32(f1.GetValue("\\d+", RowsPerPageTextBox.Text)); SearchBtn.Enabled = false; PageList.Enabled = false; BackBtn.Enabled = false; NextBtn.Enabled = false; PageList.Items.Clear(); Thread SearchThread = new Thread(new ParameterizedThreadStart(SearchItem)); SearchThread.IsBackground = true; if (ItemNameTextBox.Text.Trim().Length > 0) { SearchThread.Start(ItemNameTextBox.Text.Trim()); } else { SearchThread.Start("%"); } }