Solved

How To Dynamically Set Width to Panel Control?

Posted on 2002-06-17
6
206 Views
Last Modified: 2010-04-14
Hi All,

I have an ASP .Net webform, where I have a Panel control.

I am dynamically creating HyperLink controls, and I am binding them to the Panel control.

My problem is setting the width of the Panel control.  If the text of a Hyperlink control is short enough where it leaves room for the next Hyperlink control, the next one fills on the same line.

At the same time, if the text of a HyperLink control goes beyond the width of the Panel control it will split into two lines.

For example, say I have three Hyperlink controls.  The first one's text is Setup, and the second's text is Transaction, and the third's text is Post Transaction.

If I make the width of the Panel control wide enough to hold the third Hyperlink's text "Post Transaction", the first line will read "Setup Transaction", instead of "Setup", and the second line being "Transaction".

I cannot find a property in the Panel control that will force objects to list one at a time like a ListView, Listbox, etc.

I've been through capturing the width of the Hyperlink controls and trying to set the width of the Panel control by those values, but nothing works, due to the nature of the length of the text values.

I've set the Wrap property to True, because False keeps all object on the same line.

I've even added VbCrLf at the end of the text value of the Hyperlink controls when creating and binding them, but it doesn't help at all.

Does anyone have any ideas?

Thanks

RichW
0
Comment
Question by:RichW
6 Comments
 
LVL 22

Accepted Solution

by:
CJ_S earned 100 total points
ID: 7084194
instead of vbCrLf try "<br>"

....your line ... & "<br>"

CJ
0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 7084388
Depending on client browser, Panl control emits <div> or <table> tag.
You best bet would be to eith add Panl control inside the Panel control for eacj Hyperlink control. Or you can add a lieral control after each Hyperlink control. And text of literal control will be set to "<br>"
0
 

Expert Comment

by:edyang75
ID: 7086889
I'd rather use a Table control to achieve your purpose; I'll put each link in a new row.

Reason: Table control renders as standard HTML TABLE element ; if you do not set its (and the TDs') width to a fixed value, its width will grow as needed.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 4

Author Comment

by:RichW
ID: 7087857
Hi All,

I figured the problem out on my own, but the site went down yesterday, and I couldn't delete the question.

My answer is to place this line right after I add the HyperLink controls to the Panel control in my class:

frm.Panel1.Controls.Add(New LiteralControl("<br>"))

Since CJ_S was the closest to this answer I am awarding the points, but thanks to everyone who responded!
RichW
0
 
LVL 4

Author Comment

by:RichW
ID: 7087882
I just realized that naveenkohli gave the answer as well.

naveenkohli, look for a Points For naveenkohli.  I will give you 50 points.

Thanks
RichW
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 7087959
Thanks!

CJ
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now