Click to See Complete Forum and Search --> : Writeing whole ListView to file
Rayman2
December 6th, 2005, 05:14 PM
hi.
i am using ListView and i need to save all list view elements to file :S
is there any way to save whole ListView
i am writeing to list this way:
Meritve is the name of listView
this->StatiskitaNalisti= gcnew ListViewItem(this->EditImeRobota->Text->ToString());
this->StatiskitaNalisti->SubItems->Add("NE DELA");
this->StatiskitaNalisti->SubItems->Add(this->VCasi->PovprecenSpeed.ToString());
this->StatiskitaNalisti->SubItems->Add(this->VCasi->MaxSpeed.ToString());
this->StatiskitaNalisti->SubItems->Add(this->label1->Text->ToString());
this->StatiskitaNalisti->SubItems->Add(this->LVmesniCas1->Text->ToString());
this->StatiskitaNalisti->SubItems->Add(this->LVmesniCas2->Text->ToString());
array<ListViewItem^>^temp1 = {StatiskitaNalisti};
this->Meritve->Items->AddRange(temp1);
Can some one help me because i dont have any idea :S
LP
jayender.vs
December 7th, 2005, 12:25 AM
You can use CStdioFile for writing in a file.
if helped dont forget to "Rate this post"
humptydumpty
December 7th, 2005, 12:58 AM
Read the Item From ListView and Fill Them in a Structure and now write this Structure to your File.that's all you have to fo
you can use CStdioFile or CFile or simple C FILE* or c++ stream function .that's upto you
Rayman2
December 7th, 2005, 05:15 AM
yes but there is a problem :S i dont know how to read from ListView :s is there some pointer that i can point it to ListView and then just do ++ for next element :S something like iterator in std::list :S
humptydumpty
December 8th, 2005, 02:49 AM
yes but there is a problem :S i dont know how to read from ListView :s is there some pointer that i can point it to ListView and then just do ++ for next element :S something like iterator in std::list :S
Can u go little bit more close to you question i didn't get what u want to say actually what's the problem
Marc G
December 8th, 2005, 03:14 AM
You first have to call GetListCtrl (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_clistview.3a3a.getlistctrl.asp) on your listview. This will give you a CListCtrl object reference. Then you can use GetItemCount (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_clistctrl.3a3a.getitemcount.asp) to retrieve the number of items in your listcontrol. Then you can use GetItemText (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_clistctrl.3a3a.getitemtext.asp) to get the item text for a specific item. Just loop over all the items from 0 to GetItemCount()-1.
Rayman2
December 8th, 2005, 09:10 AM
You first have to call GetListCtrl (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_clistview.3a3a.getlistctrl.asp) on your listview. This will give you a CListCtrl object reference. Then you can use GetItemCount (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_clistctrl.3a3a.getitemcount.asp) to retrieve the number of items in your listcontrol. Then you can use GetItemText (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_clistctrl.3a3a.getitemtext.asp) to get the item text for a specific item. Just loop over all the items from 0 to GetItemCount()-1.
oky i got GetItemCount() and GetItemText but i dont get CListCtrl :S what will this do :S
pls help this is first time i need to write ListView to file :S
Lp
Marc G
December 8th, 2005, 09:19 AM
I suppose you have a CListView object. Correct?
If so, suppose it is called m_listview.
You first need to call m_listview.GetListCtrl() to get a reference to a CListCtrl object. Then you can call for example GetItemCount:
m_listview.GetListCtrl().GetItemCount();
Rayman2
December 8th, 2005, 09:44 AM
I suppose you have a CListView object. Correct?
If so, suppose it is called m_listview.
You first need to call m_listview.GetListCtrl() to get a reference to a CListCtrl object. Then you can call for example GetItemCount:
m_listview.GetListCtrl().GetItemCount();
i am using http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformslistviewclasstopic.asp
not Clistview :S
Rayman2
December 8th, 2005, 01:29 PM
i found the way to write them to file but now i have a problem :S
i cant write system::string to file :S:S
can some one plis help me with some code :S
header of function that i will use to write to file is
bool Shranjevanje::ZapisiStrukturoVFile(System::String ^robot, System::String ^dat, System::String ^povspeed, System::String ^cjt, System::String ^vmesni1, System::String ^vmesni2)
i need to write to file somethin like that
<lenght of robot>robot<lenght of datum>datum....
pls help
Marc G
December 9th, 2005, 03:10 AM
i am using http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformslistviewclasstopic.asp
not Clistview :S
Ah, my mistake. I should have read it more carefully.
[ moved thread to the correct forum ]
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.