function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ranjith kumarranjith kumar 

how decrease the width of picklist field?

By default picklist will display values with width 5. But i want to decrease the width of that field.

 

I am entering numbers from 1 to 20 in picklist field. The picklist field width should be 2 only so that the values will fit into the field. How to achieve this one

 

Thanks in advance....Regards

-----------------------------------------

Ranjith

Navatar_DbSupNavatar_DbSup

Hi,

You can specify the width of the picklist in the style attribute.

 

Try the below code snippet as reference:

<apex:page >

     <apex:form >

        <apex:selectList size="1" style="width:40px;">

           <apex:selectOption itemLabel="1" itemValue="1"></apex:selectOption>

           <apex:selectOption itemLabel="2" itemValue="2"></apex:selectOption>

           <apex:selectOption itemLabel="3" itemValue="3"></apex:selectOption>

           <apex:selectOption itemLabel="4" itemValue="4"></apex:selectOption>

           <apex:selectOption itemLabel="5" itemValue="5"></apex:selectOption>

           <apex:selectOption itemLabel="6" itemValue="6"></apex:selectOption>

           <apex:selectOption itemLabel="7" itemValue="7"></apex:selectOption>

        </apex:selectList><p/>

        </apex:form>

</apex:page>

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

David Kingery 3David Kingery 3
That'll probably work for an apex:selectList picklist.  How about the same for an SObject field using a Standard Controller, especially a multi-select picklist? I've tried the followig but it did not work, regardless of what width I choose.

<!-- not working: -->
<apex:inputField label="" value="{!Custom_Object__c.Custom_Field__c}" style="width: 4\0px">