Click here to Skip to main content
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 19: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 OriginalGriff 365
1 Sergey Alexandrovich Kryukov 334
2 CPallini 275
3 DamithSL 230
4 Maciej Los 215
0 OriginalGriff 5,455
1 DamithSL 4,457
2 Maciej Los 3,885
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,115


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 17 May 2010
Copyright © CodeProject, 1999-2014
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