void wyswietlWalutyWcomboBox(ComboBox^ cBNazwaWaluty) //funkcja wyświetlająca dane w comboBoxach
{
try
{
for (int i = 0; i < dataGridView1->Rows->Count; i++)
{
if(dataGridView1->Rows[i]->Cells[0]->Value!=nullptr)
cBNazwaWaluty->Items->Add(dataGridView1->Rows[i]->Cells[0]->Value->ToString());
}
}
catch(Exception^)
{
MessageBox::Show("Nie udało się wyświetlić listy walut.");
}
}
void odczytajInformacjeOwalucie(int^ index, Label^ lPrzelicznik, Label^ lkodWaluty, Label^ lKursSredni)
{
if (dataGridView1->Rows[index]->Cells[0]->Value != nullptr)
{
lPrzelicznik->Text = dataGridView1->Rows[index]->Cells[1]->Value->ToString();
}
}
Dlaczego w wyswietlWalutyWcomboBox if(dataGridView1->Rows[i]->Cells[0]->Value!=nullptr) nie powoduje błędów, a w odczytajInformacjeOwalucie pokazuje błąd? Jeśli usunę funkcje odczytajInformacjeOwalucie, nie pokazują się żadne błędy i program działa, a przecież kod obu w funkcjach jest podobny, a nawet taki sam w niektórych miejscach.
Treść błędu:
1>------ Build started: Project: PrzelicznikWalutInC, Configuration: Debug Win32 ------
1> PrzelicznikWalutInC.cpp
1>c:\users\marcin\documents\visual studio 2010\projects\przelicznikwalutinc\przelicznikwalutinc\Form1.h(99): error C2660: 'System::Windows::Forms::DataGridView::Rows::get' : function does not take 1 arguments
1>c:\users\marcin\documents\visual studio 2010\projects\przelicznikwalutinc\przelicznikwalutinc\Form1.h(99): error C2664: 'System::Windows::Forms::DataGridViewRowCollection::default::get' : cannot convert parameter 1 from 'System::Int32 ^' to 'int'
1> No user-defined-conversion operator available, or
1> There is no context in which this conversion is possible
1>c:\users\marcin\documents\visual studio 2010\projects\przelicznikwalutinc\przelicznikwalutinc\Form1.h(99): error C2660: 'System::Windows::Forms::DataGridViewRowCollection::default::get' : function does not take 0 arguments
1>c:\users\marcin\documents\visual studio 2010\projects\przelicznikwalutinc\przelicznikwalutinc\Form1.h(99): error C2065: 'Cells' : undeclared identifier
1>c:\users\marcin\documents\visual studio 2010\projects\przelicznikwalutinc\przelicznikwalutinc\Form1.h(99): error C2227: left of '->Value' must point to class/struct/union/generic type
1>c:\users\marcin\documents\visual studio 2010\projects\przelicznikwalutinc\przelicznikwalutinc\Form1.h(101): error C2660: 'System::Windows::Forms::DataGridView::Rows::get' : function does not take 1 arguments
1>c:\users\marcin\documents\visual studio 2010\projects\przelicznikwalutinc\przelicznikwalutinc\Form1.h(101): error C2664: 'System::Windows::Forms::DataGridViewRowCollection::default::get' : cannot convert parameter 1 from 'System::Int32 ^' to 'int'
1> No user-defined-conversion operator available, or
1> There is no context in which this conversion is possible
1>c:\users\marcin\documents\visual studio 2010\projects\przelicznikwalutinc\przelicznikwalutinc\Form1.h(101): error C2660: 'System::Windows::Forms::DataGridViewRowCollection::default::get' : function does not take 0 arguments
1>c:\users\marcin\documents\visual studio 2010\projects\przelicznikwalutinc\przelicznikwalutinc\Form1.h(101): error C2065: 'Cells' : undeclared identifier
1>c:\users\marcin\documents\visual studio 2010\projects\przelicznikwalutinc\przelicznikwalutinc\Form1.h(101): error C2227: left of '->Value' must point to class/struct/union/generic type
1>c:\users\marcin\documents\visual studio 2010\projects\przelicznikwalutinc\przelicznikwalutinc\Form1.h(101): error C2227: left of '->ToString' must point to class/struct/union/generic type