Kimossab

Atualizar listview

Dec 28th, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.42 KB | None | 0 0
  1. //Chamar evento
  2.             this->tbCodBar->TextChanged += gcnew System::EventHandler(this, &Prods::tb_TextChanged);
  3.             this->tbCat->TextChanged += gcnew System::EventHandler(this, &Prods::tb_TextChanged);
  4.             this->tbFab->TextChanged += gcnew System::EventHandler(this, &Prods::tb_TextChanged);
  5.             this->tbNome->TextChanged += gcnew System::EventHandler(this, &Prods::tb_TextChanged);
  6.            
  7. //Função de atualizar a listbox (ou listview???? bolas enganeime lol) lvProds
  8.         void AtualizarListBox(string cat, string nome, string cb, string fab)
  9.         {
  10.             this->UseWaitCursor = true;
  11.             lvProds->Items->Clear();
  12.             Lista<produto> *lp;
  13.             produto *p;
  14.             int x=0;
  15.             for(int i=0; i<LC.NElem(); i++)
  16.             {
  17.                 if(cat!="" && CoisasUteis::SToUpper(LC[i]->GetNomeCat()).find(CoisasUteis::SToUpper(cat)) == string::npos) //se a categoria nao for nula e nao estiver contida nesta categoria continuar
  18.                     continue;
  19.                 lp=LC[i]->GetLP();
  20.                 for(int n=0; n<lp->NElem();n++)
  21.                 {
  22.                     if((nome!="" && CoisasUteis::SToUpper(lp->GetInfo(n)->GetNome()).find(CoisasUteis::SToUpper(nome)) == string::npos) ||
  23.                         (cb!="" && CoisasUteis::SToUpper(lp->GetInfo(n)->GetCodBar()).find(CoisasUteis::SToUpper(cb)) == string::npos) ||
  24.                         (fab!="" && CoisasUteis::SToUpper(lp->GetInfo(n)->GetFab()).find(CoisasUteis::SToUpper(fab)) == string::npos))
  25.                         continue;
  26.                     p=lp->GetInfo(n);
  27.                     ListViewItem^ Item = gcnew ListViewItem(CoisasUteis::ConverterstringToString(LC[i]->GetNomeCat()));
  28.                     Item->SubItems->Add(CoisasUteis::ConverterstringToString(p->GetNome()));
  29.                     Item->SubItems->Add(CoisasUteis::ConverterstringToString(p->GetCodBar()));
  30.                     Item->SubItems->Add(p->GetQt().ToString());
  31.                     Item->SubItems->Add(p->GetPreco().ToString());
  32.                     Item->SubItems->Add(CoisasUteis::ConverterstringToString(p->GetDataF()));
  33.                     Item->SubItems->Add(CoisasUteis::ConverterstringToString(p->GetDataV()));
  34.                     Item->SubItems->Add(CoisasUteis::ConverterstringToString(p->GetFab()));
  35.                     Item->SubItems->Add(CoisasUteis::ConverterstringToString(p->GetLoc()));
  36.                     lvProds->Items->Add(Item);
  37.                 }
  38.             }
  39.             this->UseWaitCursor = false;
  40.         }
  41.  
  42. //Evento
  43.     private: System::Void tb_TextChanged(System::Object^  sender, System::EventArgs^  e)
  44.     {
  45.         AtualizarListBox(CoisasUteis::ConverterStringTostring(tbCat->Text),CoisasUteis::ConverterStringTostring(tbNome->Text),CoisasUteis::ConverterStringTostring(tbCodBar->Text),CoisasUteis::ConverterStringTostring(tbFab->Text));
  46.     }
Advertisement
Add Comment
Please, Sign In to add comment