Link to home
Start Free TrialLog in
Avatar of penglu
penglu

asked on

How to make checkbox small in C#.net


I am using C#.net to develop a web form. I need a few very small checkbox on the form. However, the smallest that I can get from C#.net is xx-smaller.

Any idea?

Thanks,
Avatar of Rouchie
Rouchie
Flag of United Kingdom of Great Britain and Northern Ireland image

I don't believe this is possible to achieve because the operating system controls the size of the textbox, not the browser.  They are always rendered at a standard size.
I've tried this morning using html and css but neither affect the checkbox size.
Avatar of zawedikian
zawedikian

hey
u can give the checkbox a css class and in the class (for ex checkstyle),

put

.checkstyle
{
size = 10px
}
zawedikian - that doesn't work.  SIZE is not a valid CSS property name.

The correct property names, size and width do not affect the checkbox size:
   style="width:50px; height:50px"

Increasing the font size does also not work.
It wont work ,

U need to change put the following in InitializeComponent

checkbox1.Size = new System.Drawing.Size(192, 24);

By changing the values in braces u  can change size.
     
hi
Rouchie is right. i meant by size the width. in the css class, u can out width = 10px for ex.
the use of css class is better than putting them near every checkbox. bcz if u decide to change the size or the color or whatever of the checkbox, u do it in the class only and not on every checkbox.

As far as I know there is no way to alter the size of a checkbox.  Come to think of it, I have never seen this done before.  You have 2 alternatives though penglu:

 1. Use a Flash-based form (might involve learning Macromedia Flash)
 2. Use an image of a checkbox instead, and use javascript to swap it when checked
Avatar of penglu

ASKER


Hi,

Thanks for the response. Howver, I have tried using css

<style>
    input.chk {height:8px; width:8px; margin:0px;}
</style>

the size of check DOES change, but the text on the right side of the checkbox is not aligned well with the text, which is not as good as the server side checkbox.

Peng

Whoa - I've not seen that before!  Note that it doesn't work in Firefox!  All I get in Firefox is a huge white space with the normal sized checkbox in the center!
Can you use CSS to align the text?

<input type="checkbox" name="option1" value="Choice" style="height:8px; width:8px; vertical-align:middle;"> Choice<br/>

or

    <span style="vertical-align:middle;">
        <input type="checkbox" name="option1" value="Choice" style="height:8px; width:8px;"> Choice
    </span>
    <br/>
Avatar of penglu

ASKER


<input type="checkbox" name="option1" value="Choice" style="height:8px; width:8px; vertical-align:middle;"><font style="height:8px; width:8px; vertical-align:middle"> Choice</font><br/>

works OK.
hi
for the text, u can use text-padding or padding (from bottom or top)...
ASKER CERTIFIED SOLUTION
Avatar of DarthMod
DarthMod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial