Datagrid

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sachinkale
    New Member
    • Mar 2007
    • 16

    Datagrid

    how can i refres a datagrid or close and open it again.
  • radcaesar
    Recognized Expert Contributor
    • Sep 2006
    • 759

    #2
    What you want to do exactly ?

    :)

    Comment

    • sachinkale
      New Member
      • Mar 2007
      • 16

      #3
      I have written below code

      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.
      Last edited by kenobewan; Mar 1 '07, 11:28 AM. Reason: Add code tags

      Comment

      • kenobewan
        Recognized Expert Specialist
        • Dec 2006
        • 4871

        #4
        I believe that you can use GridColumnStyle s.clear() to clear all column styles or GridColumnStyle s.remove(tables tyle2) just to remove that one.

        Comment

        • sachinkale
          New Member
          • Mar 2007
          • 16

          #5
          Thank You very much

          I stored that datagridcolumns tyle to an array before adding.
          and using that array i removed datagridcolumns tyle one bye one before adding new tablestyle.

          I had worked on that code for 3 days so thanx once again.....

          Comment

          Working...