Linklabel hyperlink

A

Alain Dekker

I'm using a LinkLabel on two forms. One form shows the hyperlink (underline)
but the other does not. I cannot see any obvious difference between the two
versions.

What causes the hyperlink to appear or disappear?

Thanks,
Alain
 
J

Jeff Johnson

I'm using a LinkLabel on two forms. One form shows the hyperlink
(underline) but the other does not. I cannot see any obvious difference
between the two versions.

What causes the hyperlink to appear or disappear?

Without cracking open the help file, I believe there's a property called
LinkAreas, which defines one or more (well, really, zero or more) spans of
characters that are to be underlined. You do have at least one link area
set, right?
 
A

Alain Dekker

Thanks. That doesn't appear to be the problem because one thing I didn't
mention is that I am using the Compact Framework .NET v2 (targetting a
Windows CE device). According to the MSDN documentation, LinkAreas is not
supported in .NET Compact v2 (but is in .NET 2.0). Therefore, the hyperlink
characters should be "everything" in all CF .NET 2.0 LinkLabel controls.

In the designer.cs files, the definitions are slightly different:

[This one does NOT display the hyperlink, form1]
this.lblThreshold.ForeColor = System.Drawing.Color.Red;
this.lblThreshold.Name = "lblThreshold";
this.lblThreshold.TabStop = false;
this.lblThreshold.Click += new System.EventHandler(this.lblThreshold_Click);

[This one DOES display the hyperlink, form2]
this.lblThreshold.BackColor =
System.Drawing.Color.FromArgb(((int)(((byte)(160)))),
((int)(((byte)(160)))), ((int)(((byte)(255)))));
this.lblThreshold.Font = new System.Drawing.Font("Microsoft Sans Serif",
18F, System.Drawing.FontStyle.Regular);
this.lblThreshold.ForeColor = System.Drawing.Color.Black;
this.lblThreshold.Location = new System.Drawing.Point(205, 70);
this.lblThreshold.Name = "lblThreshold";
this.lblThreshold.Size = new System.Drawing.Size(180, 40);
this.lblThreshold.TabIndex = 2;
this.lblThreshold.Text = "500";
this.lblThreshold.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.lblThreshold.Click += new System.EventHandler(this.lblThreshold_Click);

Any thoughts?

Alain
 
J

Jeff Johnson

this.lblThreshold.Font = new System.Drawing.Font("Microsoft Sans Serif",
18F, System.Drawing.FontStyle.Regular);
Any thoughts?

Yeah: maybe because the font is EXPLICITLY "Regular" it might not be drawing
the underline. That's my only guess.
 
J

Jeff Johnson

Yeah: maybe because the font is EXPLICITLY "Regular" it might not be
drawing the underline. That's my only guess.

....and it's wrong because I just realized that this is the one that's
WORKING!

By the way, why TabStop = false? You should be able to tab (or nav
arrow--whatever) to hyperlinks.
 
A

Alain Dekker

Thanks for the suggestions, Peter. I'll copy and paste the initialisation
between the controls and try to work out what is going on. If I find out
what is causing the difference I'll test it in std desktop C# (which in
theory should be identical to CF C# of course) and post back to the group.

Thanks and regards,
Alain


Peter Duniho said:
[...]
Any thoughts?

There's nothing obvious in the code you posted. Jeff's guess about
formatting could be applicable, even if he misinterpreted the code. For
example, it may not be an explicit font that causes the problem, but
changing the font color to something other than black. But without doing
some time-consuming trial and error, an inexperienced eye can't really say
for sure.

It's possible someone with a lot of experience using that particular
control would know off the top of their head the answer. But it's also
just as possible that out of context, there's no way to answer the
question at all. It is not necessarily the case that the problem can be
found in that particular code that initializes the control.

All that said, you can easily test the theory: just copy the
initialization for the control that works to the one that doesn't and vice
a versa, and see if the behavior changes for each. If not, then you need
to look elsewhere.

If you want specific help here, you need to post a concise-but-complete
code example that reliably reproduces the problem. Of course, since this
is not a Compact Framework-specific newsgroup, it also means you either
need to post that code to a CF-specific newsgroup or you need to first
create a code example that works on the desktop.

Pete
 

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

Top