I have written below code
- Try
-
DG.TableStyles.Clear()
-
DG.Refresh()
-
sp_cnt = 0
-
-
-
DG.TableStyles.Clear()
-
tablestyle.MappingName = mdetabname
-
tablestyle.HeaderBackColor = System.Drawing.Color.Pink
-
'tablestyle.MappingName.Remove(0, Len(mdetabname))
-
-
-
Do
-
If sacarray(sp_cnt) <> "" Then
-
Dim tablestyle2 As New DataGridTextBoxColumn
-
' MsgBox(TableStyle1(0).ToString())
-
tablestyle2.MappingName = sacarray(sp_cnt)
-
tablestyle2.Width = 100
-
tablestyle2.HeaderText = MappArray(sp_cnt)
-
MsgBox(sacarray(sp_cnt) & " " & MappArray(sp_cnt))
-
-
tablestyle.GridColumnStyles.Add(tablestyle2)
-
tablestyle2.Dispose()
-
sp_cnt = sp_cnt + 1
-
-
Else
-
Exit Do
-
End If
-
Loop
-
-
-
DG.TableStyles.Add(tablestyle)
-
DG.Refresh()
sacarray() - I have taken different fields using string operation from 12 different select statements statement and stored it in "sacarray".
for
MappArray() - I m taking values from database and storing it in this array.
there are 50 different rows fro mapping array
these 50 rows are divided into 12 tables.
and mapping these two array in above code
At first it runs fine.
but when i try to apply different combination i m getting following error:
"Error: Datagrid columnstyle collection already contains a columnstyle
with the same mapping "
parameter name: column
please clarify how i can remove a columnstyle from a datagrid before applying new one.