foreach(o.list中的书b){ListBox_Items.Items.Add(b.Title); }
执行此操作后,标题现在显示在列表框中.
当我进行选择(单一模式)时,ListBox_Items(屏幕)突出显示所选行,但事件SelectedIndexChanged未触发.
protected void ListBox_Items_SelectedIndexChanged(object sender, EventArgs e)
{
int i = ListBox_Items.SelectedIndex;
}
ID="ListBox_Items" runat="server" EnableViewState="False" Width="400px" Rows="25" onselectedindexchanged="ListBox_Items_SelectedIndexChanged"
Run Code Online (Sandbox Code Playgroud)
有任何想法吗 ?
迈克尔
编辑1:感谢大家的帮助.现在就开始工作了.无论如何,我也必须将EnableViewState打开为True.因为我有一个"删除"按钮来从列表框控件中删除项目,如果EnableViewState为False,每当我单击"删除"按钮时,列表框将再次变为空.
我有这种情况:
Dictionary<Int32, userInfo> users = new Dictionary<Int32, userInfo>();
Run Code Online (Sandbox Code Playgroud)
其中Int32是用户标识,userInfo包含名称和其他详细信息.我想在表单中显示一个名单列表,并允许使用该程序的人双击一个以打开一个窗口(类似于MSN messenger中发生的情况).当双击用户的名字时,我需要知道id,所以我可以这样做
OpenChatWindow(Int32 id, string name);
Run Code Online (Sandbox Code Playgroud)
我真的不知道该怎么做,我正在使用winforms.我想到了ListBox,但又一次,我不确定如何.我该怎么办?
PS.userInfo.name在Dictionary中是唯一的,但我真的不想开始寻找它.
我有一个带有值列表框的管理页面.用户还可以通过一些jquery更改值的顺序,理论上我们将保存该顺序,它将在其他一些异国情调的语言环境中更改列表框中的显示顺序.
jquery运行正常.当用户保存时,我使用此代码来处理列表框:
index = 0;
foreach (ListItem item in lstProspectStatus.Items)
{
//Save that particular item's data, using index as the value for the
//display sequence field.
index++;
}
Run Code Online (Sandbox Code Playgroud)
问题是,Items集合正在返回填充控件时所在项目的顺序.客户端订单更改将被忽略.
对我来说,最好的方法是什么?
我有一个文件存储了一些文本.现在我想用列表框显示文本gtk.我怎样才能做到这一点?
值也在动态变化.有没有办法刷新列表框?
我在第5行收到错误,listCell.Count()尝试使用listCell.Items.Count()解决它,但这不起作用......任何想法?错误:不包含count的定义.
int listCellCounter = 0;
for (int x = 0; x < listId.Items.Count; x++)
{
Console.WriteLine("something " + listId.Items[x] + " " + listCell.Items[listCellCounter]);
if (listCellCounter == listCell.Count() - 1)
{
listCellCounter = 0;
}
else
{
listCellCounter += 1;
}
}
Run Code Online (Sandbox Code Playgroud) 有一种方法来检查列表框是否连接到datascource?
我的意思是这样的
if (listbox1.datascource.enabled == true)
....
Run Code Online (Sandbox Code Playgroud) 我有一个TListBox,加载时可以有一个很长的字符串列表,所以我让操作员通过单击按钮启动一个排序.有时排序可能需要一分钟,操作员仍然想知道发生了什么.
有什么方法可以使用TProgressBar来表明发生了什么事吗?如果是这样,怎么样?
要么
我可以在开始时使用灰色(视觉上禁用)屏幕,然后在完成排序时将颜色变回白色吗?如果是这样,怎么样?
谢谢
我已经成功地完成了我BackgroundWorker的工作WinForm.它工作正常,但实际上它没有.从下面可以看出,我的形式有一个listbox以及一个Progress Bar.我正在使用它们来显示在一个文件中写一个收件人列表的进度for loop.我知道这个过程运行得太快了.每次写入一行时,都会listbox显示" 添加x个y收件人 "消息并删除其自身的最后一个条目,以便不会有太多文本.还有每个插入物,progress bar必须迈出一步.

当我在每次写入中添加1ms延迟时,程序工作正常Thread.Sleep(1).我的表单仍然可以在桌面上移动,表单看起来很正常.但是当我删除这个睡眠时(这是真实场景),表单会冻结,就好像我从未使用过并行BackgroundWorker开始一样.我怎样才能克服这个问题?
以下是我的BackgroundWorker DoWork()和ProgressChanged()事件:
做工作:
private void backgroundWorkerConvertDatatableToFile_DoWork(object sender,
DoWorkEventArgs e)
{
try
{
StringBuilder sb = new StringBuilder();
IEnumerable<string> columnNames = dt.Columns.Cast<DataColumn>().
Select(column => column.ColumnName);
sb.AppendLine(string.Join(GetDelimiter(campaignOutputFormat), columnNames));
backgroundWorkerConvertDatatableToFile.ReportProgress(-1,
dt.Rows.Count.ToString() + " recipients found.");
for (int i = 0; i < dt.Rows.Count; i++)
{
IEnumerable<string> fields = dt.Rows[i].ItemArray.Select(
field => field.ToString());
sb.AppendLine(string.Join(GetDelimiter(campaignOutputFormat), fields));
backgroundWorkerConvertDatatableToFile.ReportProgress(i, …Run Code Online (Sandbox Code Playgroud) 我想对ListBox是否为空进行检查,例如:
if {Listbox.Items is empty} then
begin
Listbox.Items.Add('Item');
end else
begin
//do somthing else
end;
Run Code Online (Sandbox Code Playgroud)
检查Listbox.Items或Listbox是否为空的部分对我来说有点困难。我试图找出一种方法,但是由于我还是Delphi的初学者,所以我失败了。如何在Delphi XE5中实现呢?
所以,我为GWT应用程序提供了ListBox的自定义实现
它的xml代码如下所示:
<g:FlowPanel addStyleNames="{style.yearRangePanel}">
<g:FlowPanel addStyleNames="{style.rangeSeparator} {style.paddingTop}">
<g:Label addStyleNames="{style.horizontalAlign}" ui:field="integerRangeDropdownLabel">Filter studies by range of enroled patients: </g:Label>
<g:Label addStyleNames="{style.prefixSpace} {style.horizontalAlign}" ui:field="startSampleSizeLabel"/>
</g:FlowPanel>
<g:FlowPanel ui:field="integerRangeDropdownFilterPanel" addStyleNames="{style.yearRangeSliderPanel} {style.paddingTop}">
<g:ListBox ui:field ="integerRangeDropdownListBox" styleName="{style.customListBox}"/>
</g:FlowPanel>
</g:FlowPanel>
Run Code Online (Sandbox Code Playgroud)
它的主要java代码如下:
@UiConstructor
public IntegerRangeDropdownFilterComposite (String fieldName, String labelText){
this.initWidget(uiBinder.createAndBindUi(this));
filterChangedEvent = new FilterChangedEvent(fieldName);
FilterConfig filterConfig = clientFactory.getApplicationContext().getConfig(FilterConfig.class);
List<FilterSetting> filterSettings = filterConfig.getFilterConfigBy(fieldName);
FilterSetting filterSetting = filterSettings.get(0);
filterByIntegerRangeSettings = (FilterConfig.FilterByIntegerRangeSettings) filterSetting;
this.increment = Integer.toString(filterByIntegerRangeSettings.getIncrement());
this.minSampleSize = Integer.toString(filterByIntegerRangeSettings.getInitialValue());
this.maxSampleSize = Integer.toString(filterByIntegerRangeSettings.getEnd());
this.setupConfig(fieldName);
}
private void setupConfig(String fieldName){
setupRange(fieldName);
}
@Override
protected …Run Code Online (Sandbox Code Playgroud)