Find html label associated with a given input

If you are using jQuery you can do something like this $(‘label[for=”foo”]’).hide (); If you aren’t using jQuery you’ll have to search for the label. Here is a function that takes the element as an argument and returns the associated label function findLableForControl(el) { var idVal = el.id; labels = document.getElementsByTagName(‘label’); for( var i = … Read more

Intelligent point label placement in R

First, here’s the results of my solution to this problem: I did this by hand in Preview (very basic PDF/image viewer on OS X) in just a few minutes. (Edit: The workflow was exactly what you’d expect: I saved the plot as a PDF from R, opened it in Preview and created textboxes with the … Read more

How to set different label for launcher rather than activity title?

Apparently <intent-filter> can have a label attribute. If it’s absent the label is inherited from the parent component (either Activity or Application). So using this, you can set a label for the launcher icon, while still having the Activity with it’s own title. Note that, while this works on emulators, it might not work on … Read more

Word wrap for a label in Windows Forms

Actually, the accepted answer is unnecessarily complicated. If you set the label to AutoSize, it will automatically grow with whatever text you put in it. (This includes vertical growth.) If you want to make it word wrap at a particular width, you can set the MaximumSize property. myLabel.MaximumSize = new Size(100, 0); myLabel.AutoSize = true; … Read more

How to create a checkbox with a clickable label?

Method 1: Wrap Label Tag Wrap the checkbox within a label tag: <label><input type=”checkbox” name=”checkbox” value=”value”>Text</label> Method 2: Use the for Attribute Use the for attribute (match the checkbox id): <input type=”checkbox” name=”checkbox” id=”checkbox_id” value=”value”> <label for=”checkbox_id”>Text</label> NOTE: ID must be unique on the page! Explanation Since the other answers don’t mention it, a label … Read more

Rotating and spacing axis labels in ggplot2

Change the last line to q + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) By default, the axes are aligned at the center of the text, even when rotated. When you rotate +/- 90 degrees, you usually want it to be aligned at the edge instead: The image above is from this blog … Read more

Transparent control over PictureBox

The Label control supports transparency well. It is just that the designer won’t let you place the label correctly. The PictureBox control is not a container control so the Form becomes the parent of the label. So you see the form’s background. It is easy to fix by adding a bit of code to the … Read more

Vertical (rotated) label in Android

Here is my elegant and simple vertical text implementation, extending TextView. This means that all standard styles of TextView may be used, because it is extended TextView. public class VerticalTextView extends TextView{ final boolean topDown; public VerticalTextView(Context context, AttributeSet attrs){ super(context, attrs); final int gravity = getGravity(); if(Gravity.isVertical(gravity) && (gravity&Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) { setGravity((gravity&Gravity.HORIZONTAL_GRAVITY_MASK) | … Read more