Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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

You can make it a region by:


#Region "Here is an if statement"

' some code here

#End Region
 
Share this answer
 
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.
 
Share this answer
 
v2
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 !
 
Share this answer
 
It seems that it's only possible with C# but not with VB.NET :sigh:
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900