如果listbox中是对象,那么该怎样正确序列化 items是用addobject加入的savetofile只能保存str怎样正确序列化对象? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你连对象也要保存吗? 那就用TWriter试试吧! protected void btnLeft_Click(object sender, EventArgs e) { string value = ""; int itemCount = ListBox1.Items.Count; if (ListBox1.Items.Count > 0) { if (ListBox1.SelectedIndex >= 0) { for (int i = 0; i < itemCount; i++) { if (ListBox1.Items[i].Selected) { ListBox2.Items.Add(ListBox1.Items[i]); } } for (int i = 0; i < itemCount; i++)//这个循环需要注意itemCount;下面每删除一个item,listbox的item数量就会少一个,所以此 { //处不能使用 ListBox1.Items.Count!!!否则会删除不彻底!!! ListBox1.Items.Remove(ListBox1.SelectedItem); } } else { value = "alert('请在右侧选择科室!');"; ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "key", value, true); } } else { value = "alert('右侧无科室!');"; ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "key", value, true); } } 建议楼主看一下TObjectList,可能会满足你的要求。 TObjectList没有从tpersistence继承,怎么会序列化???还有什么办法 WriteComponentResFileReadComponentResFile试一下,保存tcompnent及其属性 楼主需要做的是自己实现一种序列化的机制,也就是自己给每一个ITEM定一个数据结构,哪一部分是ITEM本身的属性,哪一部分是对象的属性。然后用此格式循环把数据都写到文件中。读出来的时候,自己根据自己的格式,来进行反序列化,把数据写回到列表中就可以了。 数据校验问题(上一帖错误结贴) 保存路径 请教各位大侠,COM+认证的问题 如何判断MDI窗体的某个子窗体是否被create? 关于TREEVIEW的用法!!在线等 请问执行一个事件的时候,同时响应其它事件和中断事件的方法? 大菜問題請教:怎麼制作打印程序? 以后来这里混了!入乡随俗,在这里得要尊敬这里的气氛! delphi中统计表数据导出到本地的方法 请问各位朋友,有谁买过delphi软件的吗?如何知道自己买的是正版的呢? adoquery 如何查询数据库 Delphi的问题
那就用TWriter试试吧!
{
string value = "";
int itemCount = ListBox1.Items.Count;
if (ListBox1.Items.Count > 0)
{
if (ListBox1.SelectedIndex >= 0)
{
for (int i = 0; i < itemCount; i++)
{
if (ListBox1.Items[i].Selected)
{
ListBox2.Items.Add(ListBox1.Items[i]);
}
}
for (int i = 0; i < itemCount; i++)//这个循环需要注意itemCount;下面每删除一个item,listbox的item数量就会少一个,所以此
{ //处不能使用 ListBox1.Items.Count!!!否则会删除不彻底!!!
ListBox1.Items.Remove(ListBox1.SelectedItem);
}
}
else
{
value = "alert('请在右侧选择科室!');";
ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "key", value, true);
}
}
else
{
value = "alert('右侧无科室!');";
ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "key", value, true);
}
}
ReadComponentResFile
试一下,保存tcompnent及其属性