多列DROPDOWNLIST - 使用不同的颜色为每列 [英] Multicolumn dropDownList - use different colors for each column

查看:178
本文介绍了多列DROPDOWNLIST - 使用不同的颜色为每列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ASP页此下拉列表:

I have this drop down list in an Asp page:

 for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  {
   DropDownList1.Items.Add(string.Format("{0:}", ds.Tables[0].Rows[i]["Pnum"]) +
   spacer + (ds.Tables[0].Rows[i]["Project"]) + spacer +
   (ds.Tables[0].Rows[i]["Description"]));
   }

这很好地显示了这样的事情:

which nicely shows something like this:

我知道琴弦没有颜色属性。
不过,我想知道如果有一种方式来获得不同的颜色显示DROPDOWNLIST的内容?像这样的:

I know that strings do not have a color property. However, I am wondering if there is a way to get the content of the dropDownList displayed in different colors? Like this:

推荐答案

用一个简单的DropDownList你不能有这种行为。
你可以用这样一个DropDownList定制有此

with a simple dropdownlist you cannot have this behavior. You can have this with a dropdownlist custom like this

<div>
    <input readonly type="text" style="color:red" id="t1">
    <input readonly type="text" style="color:yellow" id="t2">
    <select id="sel" style="float:right" >
    <option id="p1,p2">p3</option>
    <option id="p4,p5">p6</option>
    <option id="p7,p8">p9</option>
    </select>
</div>

CSS

input{
 margin: 0px;
 padding: 0px
 border-width:0px;
 border-color:white;
 border-style: none;
}
div{
 border-style: solid;
 border-width: 1px;
 border-color: black;                
}

JS

$(document).ready(function(){

    $("#sel").change(function(){

    var ar = $("#sel option:selected").attr("id").split(",")                ;

    $("#t1").val(ar[0]);
    $("#t2").val(ar[1]); 
    }); 
});

http://jsfiddle.net/Db8bf/

有什么工作

这篇关于多列DROPDOWNLIST - 使用不同的颜色为每列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆