public Dictionary<string, SomeObject> DictionaryVar= new Dictionary<string, SomeObject>();
foreach (SomeObject ojv in DictionaryVar.Values)
{
if (dt.Rows.Find(obj.FirstName()) == null)
{
dt.Rows.Add(new object[] { false, obj.FirstName(), "", "", 0 });
}
}
我试过这个但它不工作..我试图通过循环浏览一些对象来填充jtable,通过检查该字段是否存在,如果它不存在,然后我将它添加到表中。
for (SomeObject bs : DictionaryVar.values()) {
System.out.println("not getting inside");
for (int i = 0; i < jTable1.getRowCount(); i++) {
if (!jTable1.getValueAt(i, 1).equals(bs.FirstName())) {
((DefaultTableModel) jTable1.getModel()).addRow(new Object[]{false, bs.FirstName(), "", "", 0, ""});
} else {
}
}
}
System.out.println("the program is outputing this");
if (ListBookMark.size() > 0) {
for (SomeObject bs : DictionaryVar.values()) {
System.out.println("working now");
if (jTable1.getModel().getColumnName(1).equalsIgnoreCase(bs.GetName()) == false) {
((DefaultTableModel) jTable1.getModel()).addRow(new Object[]{false, bs.GetName(), "", "", 0, ""});
}
}
}else {
System.out.println("bs size = " + (ListBookMark.size() ));
}