【问题标题】:Getting Values from DataGridView into 2D array将 DataGridView 中的值获取到二维数组中
【发布时间】:2013-07-28 07:37:14
【问题描述】:

我想从 datagridview 中获取所有值并设置 2D 双数组。我尝试了很多语法,但它不起作用。这是代码,它在转换期间给出访问冲突异常

public ref class Form1 : public System::Windows::Forms::Form
{
    int **KillRatetemp;
    double **Costtemp;

public:
    Form1(void)
    {
        InitializeComponent();
        KillRatetemp=new int*[26];
        Costtemp=new double*[26];

        for(int i=0;i<26;i++)
        {
            KillRatetemp[i]=new int[9];
            Costtemp[i]=new double[9];
        }
      }



    void SetValues()
            {
     dataGridView1->Rows->Add(27);
     dataGridView2->Rows->Add(27);




         for(int i=0;i<=26;i++)
         {
             for(int j=0;j<=9;j++)
             {
                 dataGridView1->Rows[i]->Cells[j]->Value="1";
                 dataGridView2->Rows[i]->Cells[j]->Value="1";
             }
         }

//它适用于i

    for(int i=0;i<=26;i++)
    {
        for(int j=0;j<=9;j++)
        {

          Costtemp[i][j]= System::Convert::ToDouble(dataGridView1->Rows[i]->Cells[j]->Value);
          KillRatetemp[i][j]= System::Convert::ToDouble(dataGridView2->Rows[i]->Cells[j]->Value);
           }
       }


 };

之后我想再次将二维数组放置在 Datagridview 中。 我正在使用 Visual Studio 2010 Windows 窗体应用程序,纯 MSIL 通用语言运行时支持。 请解决我的问题。在此先感谢

【问题讨论】:

    标签: c++ for-loop access-violation multidimensional-array nested-loops


    【解决方案1】:

    Int 类型到 Double 类型的转换

    【讨论】:

    • 不,这不是问题
    猜你喜欢
    • 1970-01-01
    • 2011-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多