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

Discussion in 'ASP .Net Building Controls' started by Rob Mayo, Jul 21, 2003.

  1. Rob Mayo

    Rob Mayo Guest

    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
    Rob Mayo, Jul 21, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stephen

    flowlayout vs. gridlayout

    Stephen, Dec 5, 2003, in forum: ASP .Net
    Replies:
    5
    Views:
    5,918
    mikeb
    Dec 5, 2003
  2. Antonio Ambrosio
    Replies:
    2
    Views:
    392
    gemel
    Nov 30, 2004
  3. Replies:
    1
    Views:
    3,796
    JIMCO Software
    Sep 9, 2005
  4. luqman
    Replies:
    1
    Views:
    417
    Scott M.
    Nov 22, 2007
  5. Rob Mayo
    Replies:
    0
    Views:
    115
    Rob Mayo
    Jul 21, 2003
Loading...

Share This Page