看板 Visual_Basic 關於我們 聯絡資訊
請問大家一下 小弟想把Datagrid 裡面的其中一個column 裡面的cell,依 user 告訴我的邏輯, 變換 backcolor.(顏色按照cell裡面的值(ARGB))但是不知道該如何下手. 找了討論區的文章 ,是有找到 有關Winform DataGrid 裡面的Cell 要變換backcolor http://forums.microsoft.com/MSDN-CHT/ShowPost.aspx?PostID=865695&SiteID=14 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load SqlDataAdapter1.Fill(Ds1) Dim ts As DataGridTableStyle = New DataGridTableStyle ts.MappingName = "Products" Dim colUnitPrice As DataGridColorColumn = New DataGridColorColumn colUnitPrice.MappingName = Ds1.Tables("Products").Columns(2).ColumnName colUnitPrice.Format = "C" colUnitPrice.Alignment = HorizontalAlignment.Right colUnitPrice.HeaderText = "單價" ts.GridColumnStyles.Add(colUnitPrice) DataGrid1.TableStyles.Add(ts) End Sub 不過,在MappingName 時,是Ds1.Tables("Products").Columns(2).ColumnName 請問有沒有什麼方式,不要使用Columns(2)的方式,是否可直接指定欄位名稱? 因為用算欄位順序方式,改天如果sql改了,欄位順序改變了,會麻煩。 從 DataGridColumnStyle下手可以嗎~? 如果可以,請問該如何作?? 請問各位前輩能否提供意見給小弟 感激不盡 -- -- Robbin Lee http://0rz.tw/cb4mb (Google 搜索) http://0rz.tw/714kc (Yahoo 搜索) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 211.74.221.130