本文整理汇总了C#中System.Web.UI.WebControls.ListBox类的典型用法代码示例。如果您正苦于以下问题:C# ListBox类的具体用法?C# ListBox怎么用?C# ListBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListBox类属于System.Web.UI.WebControls命名空间,在下文中一共展示了ListBox类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateChildControls
protected override void CreateChildControls()
{
if (this.Field != null && this.ControlMode != SPControlMode.Display)
{
if (!this.ChildControlsCreated)
{
CustomDropDownList field = this.Field as CustomDropDownList;
base.CreateChildControls();
/*
MultiLookupPicker = (GroupedItemPicker)TemplateContainer.FindControl("MultiLookupPicker");
BuildAvailableItems(ref MultiLookupPicker);
SelectCandidate = (SPHtmlSelect)TemplateContainer.FindControl("SelectCandidate");
SelectResult = (SPHtmlSelect)TemplateContainer.FindControl("SelectResult");
AddButton = (HtmlButton)TemplateContainer.FindControl("AddButton");
RemoveButton = (HtmlButton)TemplateContainer.FindControl("RemoveButton");
*/
left_box = (ListBox)TemplateContainer.FindControl("LeftBox");
if (left_box.Attributes["done"] == null)
{
BuildAvailableItems(ref left_box);
}
right_box = (ListBox)TemplateContainer.FindControl("RightBox");
add_button = (Button)TemplateContainer.FindControl("AddButton");
add_button.Click += new EventHandler(add_button_Click);
remove_button = (Button)TemplateContainer.FindControl("RemoveButton");
remove_button.Click += new EventHandler(remove_button_Click);
}
}
}
开发者ID:karayakar,项目名称:SharePoint,代码行数:33,代码来源:MultipleCustomDropDownListControl.cs
示例2: CreateChildControls
protected override void CreateChildControls()
{
CustomersList = new ListBox();
CustomersList.Rows = 4;
Controls.Add(CustomersList);
}
开发者ID:Helen1987,项目名称:edu,代码行数:7,代码来源:CustomerEditor.cs
示例3: McmsWebQuestion
public McmsWebQuestion(string strId, bool bRequired, string strRequiredText, string strQuestion, string strControlBase, RepeatDirection rdLayout, string[] strResponses)
: base(strId, "mcms", bRequired, strRequiredText, strQuestion)
{
this.m_listBox = new ListBox();
this.m_checkBoxList = new CheckBoxList();
this.m_listControl = null;
if (strControlBase == "checkbox")
{
this.m_checkBoxList.RepeatDirection = rdLayout;
this.m_listControl = this.m_checkBoxList;
}
else
{
this.m_listBox.SelectionMode = ListSelectionMode.Multiple;
this.m_listControl = this.m_listBox;
}
foreach (string text in strResponses)
{
this.m_listControl.Items.Add(new ListItem(text));
}
this.m_listControl.ID = "lst_" + strId;
this.Controls.Add(this.m_listControl);
if (bRequired)
{
ListControlValidator child = new ListControlValidator();
child.EnableClientScript = false;
child.Text = strRequiredText;
child.Display = ValidatorDisplay.Dynamic;
child.ControlToValidate = this.m_listControl.ID;
this.Controls.Add(child);
}
this.Controls.Add(new LiteralControl("</p>"));
}
开发者ID:italiazhuang,项目名称:wx_ptest,代码行数:33,代码来源:McmsWebQuestion.cs
示例4: SortListBox
private void SortListBox(ListBox list_box)
{
ArrayList ListBoxArray = new ArrayList();
int i = 0;
while (i < list_box.Items.Count)
{
ListBoxArray.Add(list_box.Items[i].Text);
++i;
}
list_box.Items.Clear();
ListBoxArray.Sort();
i = 0;
while (ListBoxArray.Count > i)
{
list_box.Items.Add(ListBoxArray[i].ToString());
++i;
}
}
开发者ID:hari316,项目名称:Projects,代码行数:30,代码来源:list.aspx.cs
示例5: SelectListItem
public static void SelectListItem(ListBox listbox, string selectedValue)
{
bool foundListItem = false;
foreach (ListItem item in listbox.Items)
{
if (item.Value == selectedValue)
{
foundListItem = true;
item.Selected = true;
}
else
{
item.Selected = false;
}
}
if (foundListItem == false)
{
ListItem item = new ListItem(selectedValue, selectedValue);
item.Selected = true;
listbox.Items.Add(item);
}
}
开发者ID:rderouin,项目名称:Benday.SampleApp,代码行数:25,代码来源:BasePage.cs
示例6: CarregarListas
public void CarregarListas(ListBox listaTodos, ListBox listaAdicionados)
{
try
{
this.listaTodos = new ListBox();
foreach (ListItem item in listaTodos.Items)
{
lstListaTodos.Items.Add(new ListItem(item.Text, item.Value));
this.listaTodos.Items.Add(new ListItem(item.Text, item.Value));
}
foreach (ListItem item in listaAdicionados.Items)
lstListaAdicionados.Items.Add(new ListItem(item.Text, item.Value));
ExcluirItensIguais();
OrdenarLista(lstListaTodos);
OrdenarLista(lstListaAdicionados);
}
catch (Exception)
{
throw;
}
}
开发者ID:GabrielMCardozo,项目名称:Sind,代码行数:25,代码来源:AssociadorDeListas.ascx.cs
示例7: _loadTemplates
private void _loadTemplates(ListBox list, string scriptType)
{
string path = IO.SystemDirectories.Umbraco + "/scripting/templates/" + scriptType + "/";
string abPath = IO.IOHelper.MapPath(path);
list.Items.Clear();
// always add the option of an empty one
list.Items.Add(scriptType == "cshtml"
? new ListItem("Empty template", "cshtml/EmptyTemplate.cshtml")
: new ListItem("Empty template", ""));
if (System.IO.Directory.Exists(abPath))
{
string extension = "." + scriptType;
//Already adding Empty Template as the first item, so don't add it again
foreach (System.IO.FileInfo fi in new System.IO.DirectoryInfo(abPath).GetFiles("*" + extension).Where(fi => fi.Name != "EmptyTemplate.cshtml"))
{
string filename = System.IO.Path.GetFileName(fi.FullName);
var liText = filename.Replace(extension, "").SplitPascalCasing().ToFirstUpperInvariant();
list.Items.Add(new ListItem(liText, scriptType + "/" + filename));
}
}
}
开发者ID:phaniarveti,项目名称:Experiments,代码行数:25,代码来源:DLRScripting.ascx.cs
示例8: Page_Load
private void Page_Load(object sender, System.EventArgs e)
{
HtmlForm frm = (HtmlForm)FindControl("Form1");
GHTTestBegin(frm);
foreach (Type currentType in TestedTypes)
ListControl_ClearSelection(currentType);
// Clearing multiple selected items:
// This cannot be tested in ListControl, because only ListBox can have multiple selection.
GHTSubTestBegin("Clear multiple selection");
System.Web.UI.WebControls.ListBox lb = new System.Web.UI.WebControls.ListBox();
GHTActiveSubTest.Controls.Add(lb);
try
{
lb.Items.Add("A");
lb.Items.Add("B");
lb.Items.Add("C");
lb.Items.Add("D");
lb.SelectionMode = ListSelectionMode.Multiple;
lb.Items[0].Selected = true;
lb.Items[1].Selected = true;
lb.Items[2].Selected = true;
lb.ClearSelection();
}
catch (Exception ex)
{
GHTSubTestUnexpectedExceptionCaught(ex);
}
GHTSubTestEnd();
GHTTestEnd();
}
开发者ID:nobled,项目名称:mono,代码行数:34,代码来源:ListControl_ClearSelection_.aspx.cs
示例9: AddInfo
public void AddInfo(TextBox txtBox, ListBox listBox, AddDelegate addMethod, GetDelegate getMethod)
{
string txt = txtBox.Text;
int addCount = 0;
DataSet ds;
if (txt != "")
{
addCount = addMethod(txt);
if (addCount <= 0)
{
MsgBox("该值已存在!");
}
}
else
{
MsgBox("不能添加空值!");
}
listBox.Items.Clear();
txtBox.Text = "";
ds = getMethod();
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
listBox.Items.Add(ds.Tables[0].Rows[i][0].ToString());
}
txtBox.Focus();
}
开发者ID:jurojinx,项目名称:LuxERP,代码行数:26,代码来源:FacilityManage.aspx.cs
示例10: PopulateListBoxFromDelimitedString
public static void PopulateListBoxFromDelimitedString(ListBox listBox, String s)
{
foreach (var item in s.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
{
var parts = item.Split(",".ToCharArray());
listBox.Items.Add(new ListItem(parts[0], parts[1]));
}
}
开发者ID:ctimmons,项目名称:cs_utilities,代码行数:8,代码来源:WebControlUtils.cs
示例11: GetListBoxItemsAsDelimitedString
public static String GetListBoxItemsAsDelimitedString(ListBox listBox)
{
return
listBox.Items
.Cast<ListItem>()
.Select(li => li.Text + "," + li.Value)
.Join(";");
}
开发者ID:ctimmons,项目名称:cs_utilities,代码行数:8,代码来源:WebControlUtils.cs
示例12: CreatelstAccount
//所有权限
private void CreatelstAccount(ListBox listcontrol, int PermissionCategoryId)
{
Johnny.CMS.BLL.Access.Permission bll = new Johnny.CMS.BLL.Access.Permission();
listcontrol.DataSource = bll.GetList(PermissionCategoryId);
listcontrol.DataTextField = "PermissionName";
listcontrol.DataValueField = "PermissionId";
listcontrol.DataBind();
}
开发者ID:jojozhuang,项目名称:Projects,代码行数:9,代码来源:permissioncontrol.ascx.cs
示例13: CreateAllItems
//所有菜单栏目
private void CreateAllItems(ListBox listcontrolleft)
{
Johnny.CMS.BLL.SystemInfo.MenuCategory bll = new Johnny.CMS.BLL.SystemInfo.MenuCategory();
listcontrolleft.DataSource = bll.GetList();
listcontrolleft.DataTextField = "MenuCategoryName";
listcontrolleft.DataValueField = "MenuCategoryId";
listcontrolleft.DataBind();
}
开发者ID:jojozhuang,项目名称:Projects,代码行数:9,代码来源:menucontrol.ascx.cs
示例14: ListBindToData
public void ListBindToData(ListBox lb, DataTable dt, string dataTextField, string dataValueField)
{
lb.Items.Clear();
lb.DataSource = dt;
lb.DataTextField = dataTextField;
lb.DataValueField = dataValueField;
lb.DataBind();
}
开发者ID:1529464062,项目名称:Asp.net,代码行数:8,代码来源:ListHelp.cs
示例15: ListBoxItem
/// <summary>
/// Initializes a new instance of the <see cref="Adf.Web.UI.DropDownListItem"/> class with the specified label and drop-down list.
/// </summary>
/// <param name="label">The <see cref="System.Web.UI.WebControls.Label"/> that defines display text of the drop-down list within <see cref="Adf.Web.UI.BasePanelItem"/>.</param>
/// <param name="listBox">The <see cref="System.Web.UI.WebControls.DropDownList"/> that defines the control which will be added into <see cref="Adf.Web.UI.BasePanelItem"/>.</param>
public ListBoxItem(Label label, ListBox listBox)
{
ListBox = listBox;
_labelControls.Add(label);
_itemControls.Add(listBox);
}
开发者ID:NLADP,项目名称:ADF,代码行数:13,代码来源:ListBoxItem.cs
示例16: TextArray
public void TextArray()
{
var lb = new ListBox();
lb.Items.Add("abc");
lb.Items.Add("def");
var arr = lb.GetTextsArray();
Assert.AreEqual(arr.Length, 2);
}
开发者ID:robert-v,项目名称:misc,代码行数:9,代码来源:ListBoxExtensions.cs
示例17: SelectNextAvailableItemInListBox
private static void SelectNextAvailableItemInListBox(ListBox listBox, Int32 previousSelectedIndex)
{
if (listBox.Items.Count == 0)
return;
else if (listBox.Items.Count == previousSelectedIndex)
listBox.SelectedIndex = listBox.Items.Count - 1;
else
listBox.SelectedIndex = previousSelectedIndex;
}
开发者ID:ctimmons,项目名称:cs_utilities,代码行数:9,代码来源:WebControlUtils.cs
示例18: getListBoxItems
public string[] getListBoxItems(ListBox lb_covit)
{
string[] arr = new string[lb_covit.Items.Count];
for (int i = 0; i < lb_covit.Items.Count; i++)
{
arr[i] = lb_covit.Items[i].ToString();
}
return arr;
}
开发者ID:mfg288,项目名称:Incubadora_Ideias,代码行数:9,代码来源:CriarIdeia.aspx.cs
示例19: MoveBetween
private void MoveBetween(ListBox from, ListBox to)
{
while(from.SelectedItem != null)
{
ListItem selected = from.SelectedItem;
from.Items.Remove(selected);
to.Items.Add(selected);
}
}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:10,代码来源:TagsRow.cs
示例20: GetSelected
protected string[] GetSelected(ListBox lb)
{
var strArr = "";
foreach(ListItem li in lb.Items)
{
if(li.Selected) strArr+=li.Value + ",";
}
return strArr.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
}
开发者ID:KerwinMa,项目名称:OurUmbraco,代码行数:10,代码来源:Details.ascx.cs
注:本文中的System.Web.UI.WebControls.ListBox类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论