Can't Resize Custom Control

Discussion in 'ASP .Net Building Controls' started by paul reed, Feb 11, 2004.

  1. paul reed

    paul reed Guest

    Hello,

    I have a web custom control that is a tree view.

    Once I place this control on my aspx page, I am not able to resize it. The
    ancors are fixed. It uses a designer that I got help with on this newsgroup,
    but I don't see why this would prevent me from resizing the control. I
    confirmed this by commenting out the use of the designer and I am still not
    able to resize the control.

    Also, when loading my treeview, the size of the tree control just grows and
    grows, it doesn't stay within the bounds of the table I have it in. No
    scroll bars ever appear. The table is not generated as part of the creation
    of the control but is already on the panel.

    Thanks in advance for any help anyone might be able to provide.

    Paul Reed
    paul reed, Feb 11, 2004
    #1
    1. Advertising

  2. can you post the code in your designer class. Without that its pretty much
    impossible to see where you are going wrong. It should resize, if your using
    a designer that is ;P
    "paul reed" <> wrote in message
    news:...
    > Hello,
    >
    > I have a web custom control that is a tree view.
    >
    > Once I place this control on my aspx page, I am not able to resize it. The
    > ancors are fixed. It uses a designer that I got help with on this

    newsgroup,
    > but I don't see why this would prevent me from resizing the control. I
    > confirmed this by commenting out the use of the designer and I am still

    not
    > able to resize the control.
    >
    > Also, when loading my treeview, the size of the tree control just grows

    and
    > grows, it doesn't stay within the bounds of the table I have it in. No
    > scroll bars ever appear. The table is not generated as part of the

    creation
    > of the control but is already on the panel.
    >
    > Thanks in advance for any help anyone might be able to provide.
    >
    > Paul Reed
    >
    >
    Alessandro Zifiglio, Feb 11, 2004
    #2
    1. Advertising

  3. Hi Paul,

    I have reviewed you post, I will do some research on this issue.

    I will reply to you ASAP.

    Thanks for your understanding.

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jeffrey Tan[MSFT], Feb 11, 2004
    #3
  4. paul reed

    Paul Reed Guest

    Thanks,

    Here is my designer code. It works fine, just shows the control when
    dragged from the toolbox and placed on a form as a rectangle with
    borders and a title.

    Public Class WebFieldPickerDesigner
    Inherits System.Web.UI.Design.ControlDesigner

    Public Overrides Function GetDesignTimeHtml() As String

    Dim sw As String = "<div style="" BORDER-RIGHT:1px solid;" + _
    "BORDER-TOP: 1px solid; BORDER-LEFT:1px solid;
    BORDER-BOTTOM: 1px solid;" + _
    "WIDTH: 200px; HEIGHT: 100px"">UDB Field Picker
    Control</div>"

    Return sw.ToString()

    End Function
    End Class

    Paul Reed
    www.jacksonreed.com

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Paul Reed, Feb 11, 2004
    #4
  5. Paul, Your designer class is associated with your control. When you resize
    the component in your designer you are actually resizing your control. In
    your div element sample, you are providing a fixed size which your designer
    is unable to manipulate,and this is why you are unable to resize it. In the
    sample below I'm getting a reference to the component your designer is
    associated with and passing its width and height. Now you are able to resize
    the div and the new width and height will be always be displayed in your
    grid

    You can further provide the styling etc, also note that the base
    implementation of GetDesignTimeHtml invokes the Render method of the
    control, thereby rendering the same HTML at design time as at run time. If
    this is the case let me know and i'll post some sample code.


    Public Overrides Function GetDesignTimeHtml() As String
    ' Component is the instance of the component or control that
    ' this designer object is associated with. This property is
    ' inherited from System.ComponentModel.ComponentDesigner.
    'Replace WebCustomControl1with the name of your custom control
    Dim Instance As WebCustomControl1 = CType(Component,
    WebCustomControl1)

    Dim sw As String = "<div style=""" & "BORDER-RIGHT:1px
    solid;BORDER-TOP: 1px solid;" & _
    "BORDER-LEFT:1px solid;BORDER-BOTTOM: 1px solid;" & "WIDTH:" &
    Instance.Width.ToString & _
    ";HEIGHT:" & Instance.Height.ToString & """>UDB Field Picker
    Control</div>"
    Return sw.ToString()
    End Function
    ""Jeffrey Tan[MSFT]"" <> wrote in message
    news:...
    >
    > Hi Paul,
    >
    > I have reviewed you post, I will do some research on this issue.
    >
    > I will reply to you ASAP.
    >
    > Thanks for your understanding.
    >
    > Best regards,
    > Jeffrey Tan
    > Microsoft Online Partner Support
    > Get Secure! - www.microsoft.com/security
    > This posting is provided "as is" with no warranties and confers no rights.
    >
    Alessandro Zifiglio, Feb 11, 2004
    #5
  6. paul reed

    Paul Reed Guest

    Jeffrey,

    Thanks...I got a partial answer to my question. One gentleman said to
    avoid not being able to resize, in the designer instead of hard coding
    the Height and Width, to do something like "Instance.Height.ToString"
    and "Instance.Width.ToString". This worked.

    However, I still wouldn't mind getting help yet on the second half of
    the question. That is, once my tree renders on my page, as I click the
    node elements and keep drilling down, the control just keeps expanding.
    It never renders any scroll bars. I tried dropping the control into a
    table thinking it would stay within the bounds of the table, but it just
    expanded the table as well. Perhaps in the CreateChildControls I should
    stick the treeview inside of a DIV?

    Thanks in advance,

    Paul Reed
    www.jacksonreed.com

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Paul Reed, Feb 11, 2004
    #6
  7. paul reed

    Paul Reed Guest

    Alessandro,

    Thanks so much, that worked just fine.

    My initial question also had a second part, if I may be so bold :)

    I drag and drop my control into a table I have on my page. At run time,
    my tree loads as expected, but as I click down through the nodes, the
    tree just keep expanding and expanding. I would have expected scroll
    bars to appear and for the control to stay within the boundaries of the
    table.

    Thanks in advance,

    Paul Reed
    www.jacksonreed.com

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Paul Reed, Feb 11, 2004
    #7
  8. Hi paul, I were in a hurry and totally forgot about the second part of your
    question, so to answer :

    YOu are partially right when wanting to wrap your treeview within div tags.
    Your div element needs to have a fixed width and height. And when the inner
    content of your div element, that is whatever you have inside this div
    exceeds and starts to grows beyond that fixed width and height you get the
    scrollbars. You have to supply the css overflow attribute to your div, heres
    a sample :

    <div style="overflow: auto; width: 100px;height: 100px">
    <!-- Your tree nodes in here, and if the width is bigger than the fixed
    width/height supplied you get horizontal, vertical scrollbars,
    espectively -->
    </div>


    "Paul Reed" <> wrote in message
    news:%...
    > Jeffrey,
    >
    > Thanks...I got a partial answer to my question. One gentleman said to
    > avoid not being able to resize, in the designer instead of hard coding
    > the Height and Width, to do something like "Instance.Height.ToString"
    > and "Instance.Width.ToString". This worked.
    >
    > However, I still wouldn't mind getting help yet on the second half of
    > the question. That is, once my tree renders on my page, as I click the
    > node elements and keep drilling down, the control just keeps expanding.
    > It never renders any scroll bars. I tried dropping the control into a
    > table thinking it would stay within the bounds of the table, but it just
    > expanded the table as well. Perhaps in the CreateChildControls I should
    > stick the treeview inside of a DIV?
    >
    > Thanks in advance,
    >
    > Paul Reed
    > www.jacksonreed.com
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    Alessandro Zifiglio, Feb 11, 2004
    #8
  9. paul reed

    Paul Reed Guest

    Alessandro,

    Thanks again...I don't know what I would do without all the help on the
    newsgroups.

    Regards,

    Paul Reed
    www.jacksonreed.com

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Paul Reed, Feb 11, 2004
    #9
  10. paul reed

    Paul Reed Guest

    Hi,

    Ok...I think I am almost there. Now, I am wrapping that DIV tag around
    my control in the CreatChildControls method. Things seem to be working
    ok...I get the scrollbar.

    However, different screens use my control. On screen might want the
    control all down the left side. Someone else might want it just in the
    upper right quadrant. The problem is, by setting fixed Height and Width
    in the DIV tag, for those that want a much longe version of the control,
    they end up being constrained by the parms set in the DIV tag...the
    control is never larger than the boundaries set there.

    It is almost as if we need assess to the width and height of the
    control, then in the CreateChildControls method, dynamically determine
    the width and height based on the actual width and height of the
    control. Problem is, I don't see how to get access to the height and
    width from within the CreateChildControls method. I tried "Me.Height"
    but it is 0...same for width.

    Am I making sense? I am not sure if I am describing it correctly.

    Regards,

    Paul Reed
    www.jacksonreed.com

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Paul Reed, Feb 11, 2004
    #10
  11. paul reed

    Paul Reed Guest

    I figured it out myself. In fact...Me did have the height and width. So,
    when wrapping the control in DIV, I just used the instances H/W.
    Everything works great.

    Paul Reed
    www.jacksonreed.com

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Paul Reed, Feb 12, 2004
    #11
  12. Hi Paul,

    Oh, I am glad you got what you want. Also, thanks Alessandro for his
    contribute in newsgroup!

    Yes, newsgroup needs all the people's participation and discuss!

    If you have any further concern, please feel free to post, we will help
    you. :)

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jeffrey Tan[MSFT], Feb 12, 2004
    #12
  13. paul reed

    Jiho Han Guest

    Let me inject something here...
    I was doing something similar and I needed my control have a scrollbar as
    needed as well. The problem for me is that I can't set the size of the DIV
    tag. That is because the DIV is set to expand to take up any slack.

    As an example, let's say that you have a table with three rows:

    <table height="100%">
    <tr><td height="22">header row</td></tr>
    <tr><td height="100%"><mycontrol></td></tr>
    <tr><td height="22">footer row</td></tr>
    </table>

    As you can see, when the browser window is resized, the second row is set to
    resize with it. And therefor my DIV tag that surrounds my control also has
    HEIGHT="100%" style set.

    So far what I've tried to do is to figure out the initial height at run-time
    in javascript and reset the height of the div tag to that fixed value. So
    if the content inside were to overflow, the DIV tag would generate a
    scrollbar for my control. Sounds all good except in practice, it doesn't
    seem to work. Maybe I'm accessing the wrong style properties as there are
    so many different "size" properties such as height, offsetHeight,
    clientHeight, scrollHeight, etc.

    Or maybe I'm just going about it the wrong way?

    Thanks much.
    Jiho

    "Alessandro Zifiglio" <> wrote in
    message news:DBuWb.6058$...
    > Hi paul, I were in a hurry and totally forgot about the second part of

    your
    > question, so to answer :
    >
    > YOu are partially right when wanting to wrap your treeview within div

    tags.
    > Your div element needs to have a fixed width and height. And when the

    inner
    > content of your div element, that is whatever you have inside this div
    > exceeds and starts to grows beyond that fixed width and height you get the
    > scrollbars. You have to supply the css overflow attribute to your div,

    heres
    > a sample :
    >
    > <div style="overflow: auto; width: 100px;height: 100px">
    > <!-- Your tree nodes in here, and if the width is bigger than the fixed
    > width/height supplied you get horizontal, vertical scrollbars,
    > espectively -->
    > </div>
    >
    >
    > "Paul Reed" <> wrote in message
    > news:%...
    > > Jeffrey,
    > >
    > > Thanks...I got a partial answer to my question. One gentleman said to
    > > avoid not being able to resize, in the designer instead of hard coding
    > > the Height and Width, to do something like "Instance.Height.ToString"
    > > and "Instance.Width.ToString". This worked.
    > >
    > > However, I still wouldn't mind getting help yet on the second half of
    > > the question. That is, once my tree renders on my page, as I click the
    > > node elements and keep drilling down, the control just keeps expanding.
    > > It never renders any scroll bars. I tried dropping the control into a
    > > table thinking it would stay within the bounds of the table, but it just
    > > expanded the table as well. Perhaps in the CreateChildControls I should
    > > stick the treeview inside of a DIV?
    > >
    > > Thanks in advance,
    > >
    > > Paul Reed
    > > www.jacksonreed.com
    > >
    > > *** Sent via Developersdex http://www.developersdex.com ***
    > > Don't just participate in USENET...get rewarded for it!

    >
    >
    Jiho Han, Feb 13, 2004
    #13
    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. Chubby Arse
    Replies:
    0
    Views:
    547
    Chubby Arse
    Oct 6, 2005
  2. Matt Sokol
    Replies:
    2
    Views:
    369
    Theo Tillotson
    Aug 7, 2003
  3. Chubby Arse

    Custom control renders table but doesn't resize at design time.

    Chubby Arse, Oct 6, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    170
    Chubby Arse
    Oct 6, 2005
  4. Replies:
    0
    Views:
    130
  5. Replies:
    2
    Views:
    1,251
    Adrienne
    Feb 13, 2005
Loading...

Share This Page