Spiel79 Posted February 16, 2004 Posted February 16, 2004 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. Quote
GetYourAnswers Posted February 16, 2004 Posted February 16, 2004 Hi Spiel79, Can you tell me at which line number are you getting this exception. GetYourAnswers Quote
Spiel79 Posted February 17, 2004 Author Posted February 17, 2004 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.