使用MySQL数据库:
我的DataGridView
结果:
我的代码
MySqlCommand cmd = new MySqlCommand("SELECT Invoices.InvoiceDate,InvoiceDetail.ProductName,InvoiceDetail.Quantity,InvoiceDetail.Discount FROM Invoices INNER JOIN InvoiceDetail ON Invoices.InvoiceID=InvoiceDetail.InvoiceID WHERE Invoices.CustomersID='" + textBox1.Text + "'", con);
MySqlDataAdapter sda = new MySqlDataAdapter();
sda.SelectCommand = cmd;
DataTable dt = new DataTable();
sda.Fill(dt);
BindingSource bs = new BindingSource();
bs.DataSource = dt;
dataGridView1.DataSource = bs;
dataGridView1.Columns[0].DefaultCellStyle.Format = "yyyy/MM/dd";
sda.Update(dt);
答案 0 :(得分:0)
您可以对gridview使用 DataFormatString =“{0:yyyy / MM / dd}”。