Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello everyone. I have a form which is supposed to refresh everytime a button on another form is clicked. Part of the code for the refresh form looks like this:

Dim testtblstyle As New DataGridTableStyle()
       testtblstyle.MappingName = "testfield"
       Dim testcolstyles As GridColumnStylesCollection
       testcolstyles = testtblstyle.GridColumnStyles
       testcolstyles.Add(testcolumn1)
       testcolstyles.Add(testcolumn2)
       testcolstyles.Add(testcolumn3)
       DataGrid1.TableStyles.Add(testtblstyle)

 

However, when executed and when the button is clicked i get this error message:

An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll

 

Additional information: The data grid table styles collection already contains a table style with the same mapping name.

 

Please let me know how to overcome this problem. Thanks.

Posted

Realised what the problem was.

Was declaring the add tablestyles command within the function so it was executing everytime the function was called, hence the error.

Managed to overcome it by declaring it in the form load event.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...