Solved

How to make checkbox small in C#.net

Posted on 2006-07-06
14
539 Views
Last Modified: 2008-02-01

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,
0
Comment
Question by:penglu
  • 5
  • 3
  • 2
  • +2
14 Comments
 
LVL 25

Expert Comment

by:Rouchie
ID: 17056604
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.
0
 
LVL 3

Expert Comment

by:zawedikian
ID: 17056771
hey
u can give the checkbox a css class and in the class (for ex checkstyle),

put

.checkstyle
{
size = 10px
}
0
 
LVL 25

Expert Comment

by:Rouchie
ID: 17056860
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.
0
 

Expert Comment

by:Priyang
ID: 17056974
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.
     
0
 
LVL 3

Expert Comment

by:zawedikian
ID: 17058033
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.

0
 
LVL 25

Expert Comment

by:Rouchie
ID: 17058068
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
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:penglu
ID: 17058400

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

0
 
LVL 25

Expert Comment

by:Rouchie
ID: 17058580
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!
0
 
LVL 25

Expert Comment

by:Rouchie
ID: 17058594
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/>
0
 

Author Comment

by:penglu
ID: 17058997

<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.
0
 
LVL 3

Expert Comment

by:zawedikian
ID: 17059013
hi
for the text, u can use text-padding or padding (from bottom or top)...
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 17677934
PAQed with points refunded (250)

DarthMod
Community Support Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Read about why website design really matters in today's demanding market.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now