private void FillComboBox0()
{
string line;
int ni; ni = fields.Length/3; this.comboBox0.Items.Clear();
for(int i = 0; i< ni; i++ ) { line = fields[i,0]; this.comboBox0.Items.Add(line); }
this.comboBox0.SelectedIndex = 0;
} private void FillComboBox(int k)
{
string line;
DataTable dt;
int ni; if (k==2) dds = initSys.ws.GetMaterielPDMList(tj1);
// if (k==3) dds = initSys.ws.GetMaterielPZVList(tj2);
if (k==4) dds = initSys.ws.GetMaterielPDMList("type <> '1'");
// if (k==5) dds = initSys.ws.GetMaterielPZVList(tj3); if (dds != null)
{
dt = dds.Tables[0];
ni = dt.Rows.Count;
if (k==2) this.comboBox2.Items.Clear();
// if (k==3) this.comboBox3.Items.Clear();
if (k==4) this.comboBox4.Items.Clear();
// if (k==5) this.comboBox5.Items.Clear();
if ( ni>0)
{
for(int i = 0; i< ni; i++ )
{
line = dt.Rows[i].ItemArray[0].ToString().Trim();
if (k==2) this.comboBox2.Items.Add(line);
// if (k==3) this.comboBox3.Items.Add(line);
if (k==4) this.comboBox4.Items.Add(line);
// if (k==5) this.comboBox5.Items.Add(line);
}
if (k==2 && this.comboBox2.Items.Count == 1) this.comboBox2.SelectedIndex=0;
// if (k==3 && this.comboBox3.Items.Count == 1) this.comboBox3.SelectedIndex=0;
if (k==4 && this.comboBox4.Items.Count == 1) this.comboBox4.SelectedIndex=0;
// if (k==5 && this.comboBox5.Items.Count == 1) this.comboBox5.SelectedIndex=0;
}
}
else initSys.TS_MessageBox("数据库访问错误!");
}
看不懂这段程序
{
string line;
int ni; ni = fields.Length/3; this.comboBox0.Items.Clear();
for(int i = 0; i< ni; i++ ) { line = fields[i,0]; this.comboBox0.Items.Add(line); }
this.comboBox0.SelectedIndex = 0;
} private void FillComboBox(int k)
{
string line;
DataTable dt;
int ni; if (k==2) dds = initSys.ws.GetMaterielPDMList(tj1);
// if (k==3) dds = initSys.ws.GetMaterielPZVList(tj2);
if (k==4) dds = initSys.ws.GetMaterielPDMList("type <> '1'");
// if (k==5) dds = initSys.ws.GetMaterielPZVList(tj3); if (dds != null)
{
dt = dds.Tables[0];
ni = dt.Rows.Count;
if (k==2) this.comboBox2.Items.Clear();
// if (k==3) this.comboBox3.Items.Clear();
if (k==4) this.comboBox4.Items.Clear();
// if (k==5) this.comboBox5.Items.Clear();
if ( ni>0)
{
for(int i = 0; i< ni; i++ )
{
line = dt.Rows[i].ItemArray[0].ToString().Trim();
if (k==2) this.comboBox2.Items.Add(line);
// if (k==3) this.comboBox3.Items.Add(line);
if (k==4) this.comboBox4.Items.Add(line);
// if (k==5) this.comboBox5.Items.Add(line);
}
if (k==2 && this.comboBox2.Items.Count == 1) this.comboBox2.SelectedIndex=0;
// if (k==3 && this.comboBox3.Items.Count == 1) this.comboBox3.SelectedIndex=0;
if (k==4 && this.comboBox4.Items.Count == 1) this.comboBox4.SelectedIndex=0;
// if (k==5 && this.comboBox5.Items.Count == 1) this.comboBox5.SelectedIndex=0;
}
}
else initSys.TS_MessageBox("数据库访问错误!");
}
看不懂这段程序
具体请看http://book.csdn.net/bookfiles/30/10030857.shtml
还有另一个意思,在<>之间加入类型参数,如<int>,这是有关泛型方面的知识。
("type <> '1'")表示
type不等于'1'
最好看看initSys.ws.GetMaterielPDMList这个方法的代码
不过除了泛型,或者SQL语句,不可能有其他!
不然就错了!