Posts Tagged ‘Visual Studio’

how to create clickable elipsis at Windows Mobile Application

October 13, 2010

how do I create a label to be ellipsis that is if the text length is greater than the length of the container label will arise … which if clicked will issue the entire text

at first enter this function in your program:

public static void LabelWrap (LinkLabel LBL)
Graphics g = FindRoot (LBL). CreateGraphics ();
LabelWrap (LBL, g);

public static void LabelWrap (LinkLabel LBL, Graphics g)
string text = lbl.Text;
textWidth int = Convert.ToInt32 (Math.Ceiling (g.MeasureString (text + “”, lbl.Font). Width));
if (textWidth> lbl.Width)
text.Substring lbl.Text = (0, (lbl.Width * text.Length / textWidth) – 3) + “…”;
_fullText [IndexControl (LBL)] = text;
lbl.Click + = new EventHandler (PDALogic.lbl_Click);
else if (_fullText.ContainsKey (IndexControl (LBL)))
_fullText.Remove (IndexControl (LBL));

then each time you fill your linklabel with a text call

LabelWrap (nama_LinkLabel);

to make it into ellipsis