0

После того, как я ввёл значения переменных (int, double и System::String^) в textBox и после хочу найти какой-нибудь элемент или удалить запись, то постоянно появляется сообщение о том, что список пуст.

    Struct Node
    {int nom;
    double v_ot;
    gcroot <String^> graf;
    Node *next, *prev;}
    Node *head, *prev;
    //...
    private: Void MyForm_Load(Object^ sender, EventArgs^ e) 
  { 
   Node* exp = new Node; 
   try { int(exp->nom) = Convert::ToInt32(textBox_nom->Text); } catch (FormatException^ e) { /*int nom = 0;*/ } 
   String^ tip; exp->tip = textBox_tip->Text; 
   String^ punkt; exp->punkt = textBox_punkt->Text; 
   try { double(exp->v_ot) = Convert::ToDouble(textBox_v_ot->Text); } catch (FormatException^ e) {}  
   try { double(exp->v_pr) = Convert::ToDouble(textBox_v_pr->Text); } catch (FormatException^ e) {} 
   try { double(exp->v_puti) = Convert::ToDouble(textBox_v_puti->Text); } catch (FormatException^ e) {} 
   String^ graf; exp->graf = textBox_graf->Text; 
   exp->next = nullptr; 
   head = exp; tail = exp; 
  } 


private: Void button_add_Click(Object^ sender, EventArgs^ e) 
  { 
   textBox_nom->Clear(); textBox_tip->Clear(); textBox_punkt->Clear(); textBox_v_ot->Clear(); textBox_v_pr->Clear(); textBox_v_puti->Clear(); textBox_graf->Clear(); 
   Node* exp = new Node; 
   try { int(exp->nom) = Convert::ToInt32(textBox_nom->Text); } catch (FormatException^ e) {} 
   String^ tip; exp->tip = textBox_tip->Text; 
   String^ punkt; exp->punkt = textBox_punkt->Text;  
   try { double(exp->v_ot) = Convert::ToDouble(textBox_v_ot->Text); } catch (FormatException^ e) {}  
   try { double(exp->v_pr) = Convert::ToDouble(textBox_v_pr->Text); } catch (FormatException^ e) {} 
   try { double(exp->v_puti) = Convert::ToDouble(textBox_v_puti->Text); } catch (FormatException^ e) {} 
   String^ graf; exp->graf = textBox_graf->Text; 
   exp->next = nullptr; 
   if (head == NULL) { head = exp; tail = exp; } 
   else { tail->next = exp; tail = exp; } 
  } 
private: Void button_out_Click(Object^ sender, EventArgs^ e) 
  { 
   if (!head) 
    MessageBox::Show("Список пуст!"); 
   if (head != nullptr) 
   { 
    textBox2->Clear(); 
    Node* exp = head; 
    while (exp != nullptr) 
    { 
     textBox2->Text = Convert::ToString(exp->nom) + "\r\n"; 
     textBox2->Text = exp->tip + "\r\n"; 
     textBox2->Text = exp->punkt + "\r\n"; 
     textBox2->Text = Convert::ToString(exp->v_ot) + "\r\n"; 
     textBox2->Text = Convert::ToString(exp->v_pr) + "\r\n"; 
     textBox2->Text = Convert::ToString(exp->v_puti) + "\r\n"; 
     textBox2->Text = exp->graf + "\r\n\r\n"; 
     exp = exp->next; 
    } 
   }; 
  }

Как решить эту проблему?

2
  • Я редактировал своё сообщение. Что я хочу сделать? Я хочу ввести данные в textBox и после нажатия кнопки button_out, эти данные должны отобразиться в другом текстовом поле textBox2.
    – Astarta
    2 июн 2022 в 8:03
  • Спасибо. Сам разобрался.
    – Astarta
    2 июн 2022 в 15:27

0

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Посмотрите другие вопросы с метками или задайте свой вопрос.