一个对话框中多个combobox从数据库中取值的问题,谢谢!
有一个数据表,里面有特征位置,特征类和特征代号。
其中所有的特征类,都可以归类到某一个特征位置里。
现在想做一个对话框,里面有几个下拉菜单(数量就是特征位置的数量)
每个下拉菜单都是一个特征位置所包含的特征细类。
我用了一个数据集。
在Load里写了如下代码
this.t_Quan_FeatureTableAdapter.FillByA(this.t_Quan_Feature._T_Quan_Feature);
comboBox3.DataSource = this.t_Quan_Feature.Tables["T_Quan_Feature"];
comboBox3.DisplayMember = "Feature";
comboBox3.ValueMember = "FeatureVal";
comboBox3.Show();
FillByA是我定义的一个查询,用来把所有属于特征位置A的特征细类都找出来,然后填充到combobox3里。
运行的时候,是有效的。
问题是,接下来如何用同样的方式把其他下拉菜单都填充好。
我重复以上代码,运行结果是两个下拉菜单都是同样的选项,而且选取其中一个,另一个也跟着变化。
谢谢大家!
[解决办法]
是不是要实现,选中一个combox的值(combox1),另一个combox(combox2)的值跟着变化啊?如果是的话,可以在combox1的selectedIndexChanged事件中写。即,但选中一个值后,combox2中才会有数据加载。
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { this.comboBox2.Items.Clear();//每次加载前清空下 this.comboBox2.Items.Insert(0, "-选择全部-"); this.comboBox2.SelectedIndex = 0; CommonExecute commExecute = new CommonExecute(m_ConnectionString); string strCondition = string.Format("corplocation='{0}' and mark='0'", this.comboBox_CorpLocation.Text.Trim()); DataSet ds = new DataSet(); if (this.comboBox1.SelectedIndex > 0) { if (commExecute.GetInfosDataSetByCondition("corporations", strCondition, null, out ds) == true) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { this.comboBox2.Items.Insert(i + 1, ds.Tables[0].Rows[i]["corpname"].ToString()); } } } }
[解决办法]
10 CCU_FClose(fp/fp_dir)101 CCU_ERR_MPI_NOT_SUPPORT_ENUM_VALUE 102
fp = 44("/sys/class/gpio/unexport", "w"); //notice: it must use w, not rw
if (52 == fp){50, "Open file fail");return 31;}43(acStrGpio, 46acStrGpio), "%d" ,wGpioNum);
(VOID)53(fp, 0, SEEK_SET);wNum = (UINT16)41(acStrGpio, 46CHAR),(UINT)45(acStrGpio), fp);
if(wNum != 45(acStrGpio)){101;50 "GPIO%d close write bytenum is %d", wGpioNum, wNum);return 32;}101;
11
43(acFileDir, 46acFileDir), "/sys/class/gpio/gpio%d/direction", wGpioNum);
fp_dir = 44(acFileDir, "rw");if (fp_dir == 52){50 "Open gpio%d direction fail", wGpioNum);return 31;}
CCU_FRead(acDirection, 46CHAR), (UINT)10, fp_dir);
if(CCU_OK == CCU_StrnCmp(acDirection, "in", 2)){*pucDirection = GPIO_DIRECTION_IN; }
else if(CCU_OK == CCU_StrnCmp(acDirection, "out", 3)){.._OUT; }
else{50 "/sys/class/gpio/gpio%d/direction error", wGpioNum);101; return 102;}101;
12 GPIO_DIRECTION_IN == ucDirection 121
/*方向只能是0或者1*/
if(ucDirection >= GPIO_DIRECTION_ENUM_END){return 102;}
54(acFileDir,'\0',CCU_FILE_PATH_LEN);
43(acFileDir, 46acFileDir), "/sys/class/gpio/gpio%d/direction", wGpioNum);
fp_dir = 44(acFileDir, "w");
if (fp_dir == 52){50 "Open gpio%d direction fail", wGpioNum);return 31;}
CCU_StrCpy(acDirection, (121) ? "in" : "out");wLen = (121) ? 2 : 3;
wRtn = (INT)41(acDirection, 46CHAR), (UINT)wLen, fp_dir);
if (wRtn != wLen){50 "write bytenum is %d, need to write[%d]", wRtn, wLen);101;return 32;}101;
13 return CCU_ERR 131
ulRet = ADP_GPIO_Open(wGpioNum);
if(CCU_OK != ulRet){50 "ADP_GPIO_Open gpio%d fail, ret[0x%lX]", wGpioNum, ulRet);return ulRet;}
43(acFileDir, 46acFileDir), "/sys/class/gpio/gpio%d/value", wGpioNum);
if(CCU_OK != ReadFileValue(acFileDir, &uTmpData))
{50 "ReadFileValue fail");131;}*pulValue = uTmpData;
14
同13CCU_Snprintf后多/*设置GPIO为输入*/(VOID)ADP_GPIO_SetDirecton(wGpioNum, GPIO_DIRECTION_IN);
15if同13
/*首先获取该GPIO的输入输出状态,若已为输出状态,直接控制管脚*/
if(CCU_OK != ADP_GPIO_GetDirecton(wGpioNum, &ucDirect))
{50 "ADP_GPIO_GetDirecton gpio%d fail", wGpioNum);131;}
if(GPIO_DIRECTION_OUT != ucDirect){/*设置GPIO为输出*/(VOID)ADP_GPIO_SetDirecton(wGpioNum, GPIO_DIRECTION_OUT);
/*回读看是否已经是GPIO输出*/if(CCU_OK != ADP_GPIO_GetDirecton(wGpioNum, &ucDirect)){..;131;}
if(GPIO_DIRECTION_OUT != ucDirect){50 "ADP_GPIO_Write gpio%d direction is not out", wGpioNum);131;}}
/*只写0 或者1*/ucValue = ucValue & 0x1;if(ucValue){aucVal[0] = '1';}else{.. '0';}
54(acFileDir,'\0',CCU_FILE_PATH_LEN);43(acFileDir, 46acFileDir),
"/sys/class/gpio/gpio%d/value", wGpioNum);fp_val = 44(acFileDir, "w");
if (fp_val == 52){50 "Open gpio%d value fail", wGpioNum);131;}wRtn = (INT)41(aucVal, 46CHAR), (UINT)1, fp_val);
if (wRtn != 1){101;50 "41 wRtn is %d,need to write[1]", wRtn);131;}101;