请解决C语言中以下代码的错误 [英] please resolve the error of below code in c sharp

查看:83
本文介绍了请解决C语言中以下代码的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void dataGridDetail_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
    {
        if (dataGridDetail.CurrentCell.ColumnIndex == 2)
        {
            var source = new AutoCompleteStringCollection();
            String[] stringArray = Array.ConvertAll<DataRow, String>(products.Select(), delegate(DataRow row) { return (String)row["code"]; });
            source.AddRange(stringArray);

            TextBox prodCode = e.Control as TextBox;
            if (prodCode != null)
            {
                prodCode.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
                prodCode.AutoCompleteCustomSource = source;
                prodCode.AutoCompleteSource = AutoCompleteSource.CustomSource;

            }
        }
    }


该代码中的产品是什么,因为它给出错误的产品,当前上下文中不存在


what is products in this code because it gives error products is not exists in the current context

推荐答案

您在哪里定义产品?
Where did you define products?
String[] stringArray = Array.ConvertAll<datarow,>(products.Select(), delegate(DataRow row) { return (String)row["code"]; });



是在事件范围内还是在全局范围内?您没有提供相应的代码.

如果尚未在全局范围内声明产品实例,则不能在事件范围内使用该产品.



is it within the scope of the event or global scope ? you did not give the code for that.

If you have not declared in the global scope an instance for products you cannot expect to use in the event scope.


这篇关于请解决C语言中以下代码的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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