创建一个搜索按钮 [英] creating a search button
本文介绍了创建一个搜索按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在表单上创建一个搜索按钮,该按钮将comboBox中的值用作主键.但是我收到错误消息,无法从"System.Windows.Forms.ComboBox"转换为"string".我该怎么办
在班上我有这个
Am trying to create a search button on my form which uses values from a comboBox as its primary key. but i get the error message cannot convert from ''System.Windows.Forms.ComboBox'' to ''string''. What should i do
In the class I have this
public bool searchstaffsalarypaymentDetails(string salaryid, string salarypurpose, string salaryyears, string salarymonths)
{
SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
表格后面有这个
Behind the form I have this
private void lklSearch5_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
try
{
clsStaffsalarypayment person5 = new clsStaffsalarypayment();
if (person5.searchstaffsalarypaymentDetails(cboStaffid5, cboPurpose, cboMonth, cboYear))
{
var
_with5 = this;
_with5.cboStaffid5.Text = person5.ID5.ToString();
推荐答案
由于您没有将ComboBox值用于searchstaffsalarypaymentDetails,因此出现错误消息方法,但ComboBox本身.
也许您应该将其重写为:
The error message occurs since you are not using the ComboBox value for the searchstaffsalarypaymentDetails method, but the ComboBox itself.
Maybe you should rewrite it as:
person5.searchstaffsalarypaymentDetails(cboStaffid5.SelectedItem.ToString(), cboPurpose.SelectedItem.ToString(), cboMonth.SelectedItem.ToString(), cboYear.SelectedItem.ToString()))
这篇关于创建一个搜索按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文