This question is locked. New answers and comments are not allowed.
I need to show/hide columns based on a selection in a combobox. The problem that I'm running into is that once a column is hidden and then I try to unhide it and set it's header to a new value, I get an "Object reference not set to an instance of an object" error.
Here's the code that's doing the showing and hiding. If I uncomment the last line in the third case statement, I get the error when the value of sService goes from "MSSQL" to anything else. As you can see, I'm setting the IsVisible property of the Misc5 column to true before trying to set the value of the header.
Any help is appreciated!
-Lee
Here's the code that's doing the showing and hiding. If I uncomment the last line in the third case statement, I get the error when the value of sService goes from "MSSQL" to anything else. As you can see, I'm setting the IsVisible property of the Misc5 column to true before trying to set the value of the header.
Any help is appreciated!
-Lee
Select Case sService |
Case "MSOLAP" |
Me.grdServices.Columns("Misc5").IsVisible = True |
Me.grdServices.Columns("Misc1").IsVisible = False |
Me.grdServices.Columns("Misc2").IsVisible = False |
Me.grdServices.Columns("Misc3").Header = "Connections" |
Me.grdServices.Columns("Misc4").Header = "Sessions" |
Me.grdServices.Columns("Misc5").Header = "Memory (kb)" |
Case "ReportServer" |
Me.grdServices.Columns("Misc5").IsVisible = True |
Me.grdServices.Columns("Misc1").IsVisible = False |
Me.grdServices.Columns("Misc2").IsVisible = False |
Me.grdServices.Columns("Misc3").Header = "Current Connections" |
Me.grdServices.Columns("Misc4").Header = "Ttl Rpts Executed" |
Me.grdServices.Columns("Misc5").Header = "Current Requests" |
Case "MSSQL", "MSSQLSERVER" |
Me.grdServices.Columns("Misc1").IsVisible = False |
Me.grdServices.Columns("Misc2").IsVisible = False |
Me.grdServices.Columns("Misc3").Header = "Connections" |
Me.grdServices.Columns("Misc4").Header = "Memory (kb)" |
Me.grdServices.Columns("Misc5").Header = "Misc5" |
'Me.grdServices.Columns("Misc5").IsVisible = False |
Case Else |
Me.grdServices.Columns("Misc1").IsVisible = True |
Me.grdServices.Columns("Misc2").IsVisible = True |
Me.grdServices.Columns("Misc5").IsVisible = True |
Me.grdServices.Columns("Misc3").Header = "Misc3" |
Me.grdServices.Columns("Misc4").Header = "Misc4" |
Me.grdServices.Columns("Misc5").Header = "Misc5" |
End Select |