datagrid嵌套的问题
datagrid1中嵌套了datagrid2,请问如何在datagrid2中动态添加列呢??
For i = 0 To dttable.Rows.Count - 1
Dim strStat As String = dttable.Rows(i).Item( "stat ")
'------------check將要填加的列名是否與已有的列重名-------------
Dim k As Integer
Dim flg As Boolean = True
For k = 0 To DS.Tables( "tblprod ").Columns.Count - 1
If strStat = DS.Tables( "tblprod ").Columns(k).ColumnName Then
flg = False
Exit For
End If
Next
'--------------------end check-----------------------------
If flg Then
Dim dgColum As New BoundColumn
dgColum.HeaderText = dttable.Rows(i).Item( "stat ")
dgColum.DataField = dttable.Rows(i).Item( "stat ")
dgColum.HeaderStyle.ForeColor = System.Drawing.Color.FromName( "#464646 ")
dgColum.HeaderStyle.CssClass = "title04 "
dgColum.ItemStyle.CssClass = "inex-content "
dgColum.HeaderStyle.Font.Size = FontUnit.op_Implicit(9)
datagrid2.Columns.Add(dgColum) //这样添加好像不行
Dim Colum As New DataColumn(dttable.Rows(i).Item( "stat "))
DS.Tables( "tblprod ").Columns.Add(Colum)
End If
Next
[解决办法]
帮LZ顶
[解决办法]
不懂,帮顶
[解决办法]
vb的不太看得懂,思路大概就是在第一个dg绑定的DataItemBound事件里面绑定第二个dg,你原来的动态添加列的代码还是放在原来的那个事件里面就好了,好像是ItemCreate事件把
[解决办法]
up!