0
在我的表單加載事件中,我設置了默認的cellstyle格式。他們沒有掌握任何人知道爲什麼?格式都不是在代碼預期後,我將DataTable綁定到網格是越來越即使代碼步驟,通過做到了datagridview格式不適用
Private Sub frmADRORD_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'wire the delegate function for incoming updates
AddHandler m_helper.DataUpdate, AddressOf UpdateGridInvoker
'bind the visual grid with the binding source
Me.datagridADRORD.DataSource = dsGridView
'get data from helper class
m_dt = m_helper.GetTable()
'bind the binding source with datatable
Me.datagridADRORD.DataSource = m_dt
**'after data loaded, auto resize columns and format
Me.datagridADRORD.AutoResizeColumn(DataGridViewAutoSizeColumnMode.AllCellsExceptHeader)
With Me.datagridADRORD.ColumnHeadersDefaultCellStyle
.BackColor = Color.Gold
.Alignment = DataGridViewContentAlignment.MiddleCenter
.WrapMode = DataGridViewTriState.True
.Font = New Font(Control.DefaultFont, FontStyle.Bold)
End With
Me.datagridADRORD.Columns("ADR Price").DefaultCellStyle.Format = "##.##"
For Each row As DataGridViewRow In Me.datagridADRORD.Rows
row.Cells("ORD Price").DataGridView.DefaultCellStyle.FormatProvider = Globalization.CultureInfo.GetCultureInfo(m_helper.CurrCultureInfoStr(row.Cells("Currency").Value))
Next
Me.datagridADRORD.Columns("Currency Price").DefaultCellStyle.Format = "##.####"
Me.datagridADRORD.Columns("Difference").DefaultCellStyle.Format = "##.##"**
End Sub