16,555
社区成员
发帖
与我相关
我的任务
分享
Dim strdd As String = "select 种类,日期,票号,客户编码,客户全称,性质,此次应付 as 金额,经手人,操作员,审核人,审核时间 from " + ComboBox2.Text + "." + "dbo" + "." + "yfa where substring(票号,5,8)=convert(char(8),cast('" + DateTimePicker1.Value + "' as datetime),112)"
Dim sqldas As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(strdd, LoginForm1.conn)
sqldas.MissingSchemaAction = MissingSchemaAction.AddWithKey
sqldas.Fill(dataset2, "sss")
datagridview2.datasource=dataset2.tables("sss")
设置他们的样式,你如果要记忆这些样式将他们保存到一个配置文件就行了,下次读取出来DataGridViewCellStyle highlightCellStyle = new DataGridViewCellStyle();
highlightCellStyle.BackColor = Color.Red;
DataGridViewCellStyle currencyCellStyle = new DataGridViewCellStyle();
currencyCellStyle.Format = "C";
currencyCellStyle.ForeColor = Color.Green
this.dataGridView1.Rows[3].DefaultCellStyle = highlightCellStyle;
this.dataGridView1.Rows[8].DefaultCellStyle = highlightCellStyle;
this.dataGridView1.Columns["UnitPrice"].DefaultCellStyle =
currencyCellStyle;
this.dataGridView1.Columns["TotalPrice"].DefaultCellStyle =
currencyCellStyle;
private void SetDefaultCellStyles()
{
this.dataGridView1.DefaultCellStyle.BackColor = Color.Beige;
this.dataGridView1.DefaultCellStyle.Font = new Font("Tahoma", 12);
DataGridViewCellStyle highlightCellStyle = new DataGridViewCellStyle();
highlightCellStyle.BackColor = Color.Red;
DataGridViewCellStyle currencyCellStyle = new DataGridViewCellStyle();
currencyCellStyle.Format = "C";
currencyCellStyle.ForeColor = Color.Green;
this.dataGridView1.Rows[3].DefaultCellStyle = highlightCellStyle;
this.dataGridView1.Rows[8].DefaultCellStyle = highlightCellStyle;
this.dataGridView1.Columns["UnitPrice"].DefaultCellStyle =
currencyCellStyle;
this.dataGridView1.Columns["TotalPrice"].DefaultCellStyle =
currencyCellStyle;
}