object不包含定义,也没有可以找到接受object类型的第一个参数的扩展方法 [英] object does not contain a definition and no extension method accepting a first argument of type object could be found

查看:1144
本文介绍了object不包含定义,也没有可以找到接受object类型的第一个参数的扩展方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误,无法解决。我已经尝试使用ListControl而不是ListBox,但是失败了(为了给'selectediten [x] .value提供组合属性),因为它给出了  无法创建实例
实例抽象类'system.window.form.listcontrol'。 

I am getting the below error and unable to resolve it. I've tried using ListControl instead of ListBox, but fail ( in order to give combine property for 'selectediten[x].value) because it is giving cannot create an instance of instance abstract class 'system.window.form.listcontrol' . 

。但是目前我正在使用ListBox,并且抛出的错误是"对象不包含定义,并且没有接受无法找到类型对象的第一个参数的扩展方法"。请帮我解决一下,并告诉我它为什么会发生? 

. However currently I am using ListBox and the error thrown are "objects does not contain a definition and no extension method accepting a first argument of type objects could not be found". Please help me solve it and can tell me why it is happened? 

如果我的屏幕截图无法读取,我已经添加了代码,我将错误加粗并加下划线。   

I've added Codes if my screen shots cannot be read, I've make the error bolded and underlined.  

谢谢。

  private void btnRetrieve_Click(object sender, EventArgs e)
        {
            try
            {
                if (cbStudyPeriod.SelectedIndex == -1)
                {
                    MessageBox.Show("Please enter study period.", titleText, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    cbStudyPeriod.Focus();
                    return;
                }
                if (rdGraduated.Checked == false && rdAllStatus.Checked == false)
                {
                    MessageBox.Show("Please check student status.", titleText, MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }
                if (cbStudyPeriod.SelectedIndex != -1)
                {

                    if (rdAllStatus.Checked == true)
                    {
                        if (StudentStatusListBox.SelectedItems.Count > 0)
                        {
                            for (int i = 0; i <= StudentStatusListBox.SelectedItems.Count - 1; i++)
                            {

                                strStatus += "," + StudentStatusListBox.SelectedItems[i].Text;


                            }

                            strStatus = strStatus.Remove(0, 1).ToString();
                        }
                        else
                        {
                            MessageBox.Show("Please select student status.", titleText, MessageBoxButtons.OK, MessageBoxIcon.Error);

                            return;

                        }
                    }

                    if (lstTuitionGrantStatus.SelectedItems.Count > 0)
                    {

                        foreach (DataRowView objDataRowView in lstTuitionGrantStatus.SelectedItems)
                        {
                            strtgdStatus += ',' + objDataRowView["lookup_id"].ToString();
                            

                        }

                        strtgdStatus = strtgdStatus.Remove(0, 1).ToString();
                    }
                    else
                    {
                        MessageBox.Show("Please select Tuition Grant Status.", titleText, MessageBoxButtons.OK, MessageBoxIcon.Error);

                        return;

                    }
                    if (rdGraduated.Checked == true)
                    {
                        if (lstStudyPeriod.SelectedItems.Count > 0)
                        {
                            for (int x = 0; x < lstStudyPeriod.SelectedItems.Count; x++)
                            {
                                graduatedDate += "," + lstStudyPeriod.SelectedItems[x].Value.ToString();
                            }
                            graduatedDate = graduatedDate.Remove(0, 1).ToString();
                        }

                        else
                        {
                            if (cbStudyPeriod.Text != "All past and current study period")
                            {
                                MessageBox.Show("Please select study period for graduated student.", titleText, MessageBoxButtons.OK, MessageBoxIcon.Error);

                                return;
                            }


                        }
                    }
                    TextViewer.Clear();







推荐答案

你好。

> 请帮我解决,并告诉我它为什么会发生? 

将ListBox中的元素放入某个变量并检查变量中的对象类型。

最有可能的类型不是您所期望的类型。

而且......我看不到你的截图......

< span style ="color:#333333; font-family:濑越UI","很好的可读性",宋体,Arial字体,黑体,无衬线; font-size:14px">


这篇关于object不包含定义,也没有可以找到接受object类型的第一个参数的扩展方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆