Take the 2-minute tour ×

I am trying to convert some code from c# to vb.net. The whole code is in http://www.codeproject.com/Articles/474418/DataGridViewplus-e2-80-93plusStackedplusHeader. I almost have it but I am running into a problem with the constructor. In C# it is passing in an interface. Like the following

    public StackedHeaderDecorator(IStackedHeaderGenerator objStackedHeaderGenerator, DataGridView objDataGrid)
        : this(objDataGrid)
        this.objStackedHeaderGenerator = objStackedHeaderGenerator;

I am not sure how to convert this to vb.net. I would really appreciate it if someone could tell me how to write the code to pass an integerface to a constructor.

share|improve this question
What did you try? What are you having trouble with? –  SLaks Nov 26 '12 at 14:50
refering to your comment to @DStanley's answer, please show the class declaration of your VB.Net class? –  jeroenh Nov 26 '12 at 15:05

1 Answer 1

You pass an interface reference just like you'd pass any type:

Sub New(objStackedHeaderGenerator As IStackedHeaderGenerator, objDataGrid As DataGridView)


    Me.objStackedHeaderGenerator = objStackedHeaderGenerator

End Sub
share|improve this answer
Thanks for your help but when I try that and get the following error message: 'objStackedHeaderGenerator' cannot expose type 'IStackedHeadeGenerator' outside the project through class 'StackedHeaderDecorator' –  Gregory Williams Nov 26 '12 at 15:00
@GregoryWilliams that is important information that you should add to your question! –  jeroenh Nov 26 '12 at 15:05
My guess is that the class this constructor belongs to is marked Public while IStackedHeaderGenerator is marked Friend/Private/Protected. This would imply that IStackedHeaderGenerator is public too which it isn't which is what the compiler is complaining about. –  Ceres Nov 26 '12 at 15:13
Here is the documentation on that issue. It sounds like that interface is private, but without seeing the source it's hard to tell. As @jeroenh suggests that would make a good follow-up question. After you do some research of course :) –  D Stanley Nov 26 '12 at 15:13

Your Answer


