方法'add'的重载在C#中没有2个参数错误 [英] No overload for method 'add' takes 2 arguments error in C#

查看:379
本文介绍了方法'add'的重载在C#中没有2个参数错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在列表框中获取值int i和j,但随后出现此错误
方法"Add"的重载没有2个参数.有人可以帮我吗.我被这个错误困扰了将近2天..

我尝试过的事情:

I try to get value int i and j in listbox, but then this error come out
No overload for method ''Add'' takes 2 arguments. Can somebody help me please. I''ve been stuck at this error almost 2 days..

What I have tried:

private void Form10_Load(object sender, System.EventArgs e)
        {
            int i;
            int j;

            for (i = 1; i <= Form9.Npmax; i++)
            {
                for (j = Form9.Nsmin_mp; j <= Form9.Nsmax_oc; j++)
                {

                    listBox1.Items.Add(i.ToString(),j.ToString());

                }
            }
        }

推荐答案

您可以这样做:
You could do it like this:
listBox1.Items.Add(i + " " + j);

如果您需要实列,请使用 ListView ,请参见此处的示例:

If you need real columns, then use a ListView, see example here: .net - Populating a listview multi-column - Stack Overflow[^]


这篇关于方法'add'的重载在C#中没有2个参数错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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