Hierarchy without dataset

Posted by: ginacresse on 8 September 2017, 1:38 pm EST

  • Posted 8 September 2017, 1:38 pm EST

    I found some sample code posted by Scott S on how to create an unbound hierarchy spread.  I copy/pasted that code into a new project but am getting a 'Parameter is not valid.' error in the following sub  at the Dim<FONT size=2> img </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>New</FONT></FONT><FONT size=2> Bitmap(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"plus.gif"</FONT></FONT><FONT size=2>) line </FONT>when I try to run it.  I'm not sure what I'm missing.  Any help is appreciated.  Thanks.


    <FONT color=#0000ff size=2><FONT color=#0000ff size=2> 

    <FONT color=#0000ff size=2><FONT color=#0000ff size=2>

    Public</FONT></FONT><FONT color=#000000 size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Overrides</FONT></FONT><FONT color=#000000 size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Sub</FONT></FONT><FONT color=#000000 size=2> PaintCell(</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT color=#000000 size=2> g </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT color=#000000 size=2> System.Drawing.Graphics, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT color=#000000 size=2> r </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT color=#000000 size=2> System.Drawing.Rectangle, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT color=#000000 size=2> appearance </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT color=#000000 size=2> FarPoint.Win.Spread.Appearance, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT color=#000000 size=2> value </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT color=#000000 size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Object</FONT></FONT><FONT color=#000000 size=2>, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT color=#000000 size=2> isSelected </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT color=#000000 size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Boolean</FONT></FONT><FONT color=#000000 size=2>, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT color=#000000 size=2> isLocked </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT color=#000000 size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Boolean</FONT></FONT><FONT color=#000000 size=2>, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT color=#000000 size=2> zoomFactor </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT color=#000000 size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Single</FONT></FONT><FONT size=2><FONT color=#000000>)</FONT>


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Dim</FONT></FONT><FONT size=2> path </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Boolean</FONT></FONT><FONT size=2> = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>True

    </FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Dim</FONT></FONT><FONT size=2> level </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Integer</FONT></FONT><FONT size=2> = 0


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Dim</FONT></FONT><FONT size=2> view </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> FarPoint.Win.Spread.SheetView = sheet


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>While</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Not</FONT></FONT><FONT size=2> (view.Parent </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Is</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Nothing</FONT></FONT><FONT size=2>)


    view = view.Parent


    level += 1


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>End</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>While

    </FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>If</FONT></FONT><FONT size=2> (</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Not</FONT></FONT><FONT size=2> (level = 0) </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>And</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Not</FONT></FONT><FONT size=2> (value </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Is</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Nothing</FONT></FONT><FONT size=2>)) </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Then</FONT></FONT><FONT size=2> path = System.IO.Directory.Exists(value.ToString())


    g.FillRectangle(Brushes.White, r)


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Dim</FONT></FONT><FONT size=2> img </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>New</FONT></FONT><FONT size=2> Bitmap(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"plus.gif"</FONT></FONT><FONT size=2>)             <<<<<<<<<<<this line returns "Parameter is not valid"


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Dim</FONT></FONT><FONT size=2> img2 </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>New</FONT></FONT><FONT size=2> Bitmap(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"minus.gif"</FONT></FONT><FONT size=2>)


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>If</FONT></FONT><FONT size=2> path </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Then

    </FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>If</FONT></FONT><FONT size=2> (</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>CType</FONT></FONT><FONT size=2>(value, State).state) </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Then

    </FONT></FONT><FONT size=2>

    g.DrawImage(img2, r.Left + 20 * level, r.Top + 3)


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Else

    </FONT></FONT><FONT size=2>

    g.DrawImage(img, r.Left + 20 * level, r.Top + 3)


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>End</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>If

    </FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>End</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>If

    </FONT></FONT><FONT size=2>

    level += 1


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Dim</FONT></FONT><FONT size=2> text </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>String</FONT></FONT><FONT size=2> = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>String</FONT></FONT><FONT size=2>.Empty


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>If</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Not</FONT></FONT><FONT size=2> (value </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Is</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Nothing</FONT></FONT><FONT size=2>) </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Then</FONT></FONT><FONT size=2> text = value.ToString


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>If</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Not</FONT></FONT><FONT size=2> (text </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Is</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>String</FONT></FONT><FONT size=2>.Empty) </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Then

    </FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Dim</FONT></FONT><FONT size=2> rr </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>New</FONT></FONT><FONT size=2> RectangleF(r.Left + 20 * level, r.Y, r.Width - 20 * level, r.Height)


    g.DrawString(text, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>New</FONT></FONT><FONT size=2> Font(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"default"</FONT></FONT><FONT size=2>, 10.0F), Brushes.Blue, rr)


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>End</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>If

    </FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>End</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Sub

    </FONT></FONT></FONT></FONT>
  • Replied 8 September 2017, 1:38 pm EST

    The .Net BitMap object has 12 overloads.  One is a file name, which is a string.  I am not sure how this code worked unless the specified gif was already in the project.
  • Replied 8 September 2017, 1:38 pm EST

    I tried creating the 2 .gif files and pasted them into my Bin folder but I continue to get the error. 


    Is there another way I can create a hierarchy spread that does not use a dataset?  We don't use databinding in our VB projects, but I need the ability to expand/collapse rows in my spread.

  • Replied 8 September 2017, 1:38 pm EST

    Hello,


    You would need to add the two gif files into your project (Solution Explorer). Also you can search the forums for unbound AND hierarchy) to find code for creating an ubound hierarchila Spread control. This is done by creating a custom SheetView object that overrides several of the methods to get at the child SheetView objects.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels