OK. I'm getting there I think. I've got the 'Text' property of the user
control working so that I can specify text, and also an additional 'Updown'
property that decides whether to show a up, down, or no arrow. But...
What I would like to do would be to set it so that I can specify the text
from the form that the control appears on, and have the control display the
arrow immediately to the right of the text. Given that I'm just using label1
and label2 as the control names, I've tried this in the text changed event of
label1 in the user control:
me.label2.left=me.label1.left+me.label1.width
me.width=me.label2.left+me.label2.width
where the autosize (? not sure on that bit, I don't have it in front of me)
property on label1 is set to true.
That's not quite working. If I change the user control text from the main
form to "this is some really quite long text" then nothing happens. If I
then change it to "a" then the control makes enough space for "this is some
really quite long text" i.e. it's lagging one step behind.
Does that make sense? Any suggestions about where I should be setting the
properties?
:
Yeah, I overlooked that. Tell VS you want to add a new item to your project,
and select "UserControl". You get what looks like a panel. Put the regular
label (or your clickable label control) on one side of the panel, and a
label formatted in Marlett on the other side. In the code, you get a class
that derives from a framework class named UserControl. Make sure the class
is declared as public.
To make that class show up in the Designer's toolbox, insert this
"decoration" just before the class declaration:
[Designer("System.Windows.Forms.Design.ParentControlDesigner,
System.Design", typeof(IDesigner))]
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
Rob Oldfield wrote:
Thanks for the info. I'm sure that that will be part of it but I'd
still (I think) need to figure out how to build a new class. The
problem is that within a standard label I'm not going to be able to
format the actual label text with one font, and then the sort
indicator with another. Unless I'm missing something obvious that
is... it wouldn't be the first time.
:
It's not quite the same appearance as the ones in the datagrid
headers, but there are triangles in the Marlett font -- type the
character "5" and format it in Marlett for the point-up triangle, and
"6" for the point-down one. Then you just need to write code in the
click event handler to change the caption string.
Marlett is a standard Windows font, used for things like the minimize
and restore buttons on app windows, so you don't have to worry about
packaging it with your program.
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
Sadly not. I'm still a bit too inexperienced to figure out exactly
how that would work. Could you provide a bit more detail on how
that would work?
(I do, by the way, have an existing third party 'clickable label'
control that I could inherit from that would handle the click event
handling.. it's just how to get the additional indicator that I'm
stuck with.)
Create your own label type class. It'd take you a few minutes to
rattle one up...
--
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
message Is there any way to get the little sort indicator (the up/down
arrow that is
visible by the column header in Explorer when you sort by a
column) on a standard label?
Note that I'm not using a datagrid - I know that they show on
those by default. I'm using a data repeater control from a third
party and I'd like
to display that indicator on the header labels of that.
Thanks.