Click here to Skip to main content
11,704,044 members (69,627 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB9.0
Hi all CodeProject member

Can you tell me how to Collapsing and Expanding in VB NET Code

Ex:

public sub Test()

- if x=1 then

'some code block

end if

end sub

when I click (-) symbol if code block to be hidden

+ if x=1 then

for code block If code block or While or Case
Not for Sub or Function or Class
thanks all suggest!
Posted 16-May-10 18:04pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can make it a region by:


#Region "Here is an if statement"

' some code here

#End Region
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Keep your '+' & '-' as image button in your application. On clicks events of that expand-collapse it using the code similar to what you wrote here.

UPDATE: That was for your UI in application. After reading another answer given, looks like it fits more to what you are asking. Use #Regions to collapse and expand.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Thanks all Support
#Region can't use any code block
it use only to function or sub
example
#Region "My Function"
public Function Myfunction()
end function
#End region
it OK but now I use to my block code ( for or if or while)
ex:
#region "My If block"
if Test=1 then
end if
#end region
it will return error
Can you tell me how to use it
Thanks !
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

It seems that it's only possible with C# but not with VB.NET Sigh | :sigh:
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 530
1 OriginalGriff 510
2 Sergey Alexandrovich Kryukov 421
3 Andy Lanng 294
4 F-ES Sitecore 220
0 OriginalGriff 8,744
1 Sergey Alexandrovich Kryukov 7,747
2 CPallini 5,107
3 Maciej Los 4,716
4 Mika Wendelius 3,606


Advertise | Privacy | Mobile
Web02 | 2.8.150819.1 | Last Updated 17 May 2010
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100