2012-07-28 200 views
0

我有一個數據網格視圖,我用數據庫填充數據源。但是,具有日期作爲其數據類型的列顯示日期和時間,而我只需要一段時間。在數據網格視圖中更改列的格式

如何更改數據網格視圖表的格式?

Private Sub prcDisplayTable() 
    dgvViewLecturers.DataSource = Nothing 
    dgvViewLecturers.Rows.Clear() 
    dgvViewLecturers.Columns.Clear() 

    strSQL = "SELECT * FROM Lecturers" 
    strTableName = "ViewLecturers" 

    daLecturers = New OleDb.OleDbDataAdapter(strSQL, con) 
    daLecturers.Fill(dsLecturers, strTableName) 

    dgvViewLecturers.DataSource = dsLecturers 
    dgvViewLecturers.DataMember = strTableName 
End Sub 

回答

1

嘗試一下本作唯一的一次格式

dataGridView1.Columns("dateColumn").DefaultCellStyle.Format = "hh:mm:ss tt"; 
+0

感謝您的幫助:) – 2012-07-29 09:17:57