FlowLayout/GridLayout from design mode: I've done it!!! :D

R

Rob Mayo

OK, dig this.

You have a custom server control you're building. You have a custom designer for that control. If you add a COM reference to MSHTML, you can determine whether the page your control sits on is in GridLayout or FlowLayout with this code in your designer:

Private Function IsPageInGridMode() As Boolean
Dim text1 As String
Dim blnResult As Boolean = False
Try
Dim element1 As mshtml.IHTMLElement
Dim element2 As mshtml.IHTMLElement

element1 = CType(MyBase.DesignTimeElement, mshtml.IHTMLElement)
element2 = CType(element1.offsetParent, mshtml.IHTMLElement)

'For now, offsetParent will get you the parent element,
'not necessarily the BODY tag. Will add recursive routine
'to get <BODY> later

text1 = element2.getAttribute("MS_POSITIONING")

If LCase(text1) = "gridlayout" Then blnResult = True
Catch e As Exception
Return false
End Try
Return blnResult
End Function

It's dirty, but it works :D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top