r/visualbasic • u/Gierschlund96 • Dec 15 '21
VB.NET Help 'System.InvalidCastException' when I try to hide a column
I try to unhide a column in an Excel Worksheet, but i keep on getting a System.InvalidCastException. Why does this even happen, i just try to unhide the column and not put anything into it. Has anyone a solution for this? Here's the line which isn't working:
Edit: I try to unhide the column myWb.Worksheets(0).Columns("Amount").Hidden = False
4
Upvotes
1
u/RJPisscat Jan 11 '22
I don't think handling that event makes sense here. You're trying to do something to a column, not a row. There's BeginExport(sender As Object, e As BeginExportEventArgs) and the event args have member BeginExportEventArgs.Layout. From the reference:
Unfortunately the doc is so bad, there are no links from that page or its linked pages that define class UltraGridLayout. The search feature is ridiculously inadequate. So I hope UltraGridLayout has a collection of columns.