|
brahmma wrote: You see, I was trying to find out if I could copy a listview object in memory to another.
Yeah I did get that, but I am not sure if you can do that. You have an option to do an AddRange which would add a listview[], but I am not sure if that would be of any help to you either.
|
|
|
|
|
Hmm... Looks like I've done a bad start with C#.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
brahmma wrote: One is in the memory, and another is in the UI.
so you have to add it twice. sure it will slow down the application.
Regards,
Satips.
|
|
|
|
|
I think you did not get it right. I wanted to know if I could copy an listview object (along with its status) to another listview object, one being in the memory and another one being in the UI.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
oh.
Regards,
Satips.
|
|
|
|
|
brahmma wrote: listView1 = lv; //Can I equate it like this?
That line does not copy the contents, it just makes listView1 refer to whatever lv was referring to. After executing that statement, both listView1 and lv refer to the same object.
Taking a guess at why you don't see the list items in the UI, you probably added listView1 to the form's Control collection i.e
form.Controls.Add(listView1);
Making listView1 refer to another object by writing listView1 = lv will not change the ListView object in the Controls collection. You can see why if you think of listView1 and lv as pointers to ListView instances (which they are).
Hope this helps.
|
|
|
|
|
S. Senthil Kumar wrote: That line does not copy the contents, it just makes listView1 refer to whatever lv was referring to. After executing that statement, both listView1 and lv refer to the same object.
Thank you. That explained the problem.
S. Senthil Kumar wrote: Making listView1 refer to another object by writing listView1 = lv will not change the ListView object in the Controls collection.
How do I copy the state (list view items) of a ListView Object that I have in memory to the object pointed by listView1, which belongs to the Controls collection?
Actually, I am retrieving data from a database and populating a ListView object with it. The UI operation seems to be slow and so I thought I would do it in the memory, and copy all the contents at once. (I miss the UpdateData(false); here. I am an MFC programmer and forgive me if I sound stupid.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
brahmma wrote: Actually, I am retrieving data from a database and populating a ListView object with it. The UI operation seems to be slow and so I thought I would do it in the memory
What exactly is the bottleneck, retrieiving data from the database or adding elements to the listview? If it's the former, you can use a separate thread to retrieve data and construct a list of ListViewItem and then use the UI thread to add the ListViewItem s to the ListView . Something like
ListView listView;
delegate void UpdateListViewDelegate(List<ListViewItem> listViewItems);
void DBDataLoaderThread()
{
List<ListViewItem> items = new List<ListViewItem>();
...
while (dataReader.Read())
{
items.Add(new ListViewItem(...));
}
listView.BeginInvoke(new UpdateListViewDelegate(UpdateListView), new object[] { items } );
}
void UpdateListView(List<ListViewItems> listViewItems)
{
foreach(ListViewItem item in listViewItems)
{
listView.Items.Add(item);
}
}
If it's the latter, you can use BeginUpdate</code. before starting to add elements to the <code>ListView and EndUpdate after it - this will prevent the ListView from repainting after adding each element.
void UpdateListView(List<ListViewItems> listViewItems)
{
listView.BeginUpdate();
foreach(ListViewItem item in listViewItems)
{
listView.Items.Add(item);
}
listView.EndUpdate();
}
|
|
|
|
|
S. Senthil Kumar wrote: If it's the latter, you can use BeginUpdateListView and EndUpdate after it - this will prevent the ListView from repainting after adding each element.
Heartfelt thanks. That is what I needed.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Hello coders,
I need an help regarding adding a button to datagridview control in my windows application.
Also i am using dataset to fill the datagridview.
Please find me the way of doing the thing.
Thanks
sulabh
Hello Forum
Always be in touch to help about the topic ASP.NET
|
|
|
|
|
sulabh2020 wrote: adding a button to datagridview
could you be more specific??
do you mean a column with buttons or what?!
life is study!!!
|
|
|
|
|
i wish i understood what u mean:
you can add a button as an object, when u write = new DataGridView(object),
you can also write = new DataGridView((Button)button1)...
|
|
|
|
|
Hi
We are using reporting service,
How to change the reporting services column header,headers...etc
into different language, in c# we use resource file and use this
resource file to change different language.
How can change these into reporting services.
Regards
Arunkumar Sundaravelu
|
|
|
|
|
Hi,
is there a tutorial somewhere that can explain how to build an internet explorer toolbar in C# on Visual Studio 2005?
I've read and tried Paul Zulnokovs article on bandobjects (http://www.codeproject.com/csharp/dotnetbandobjects.asp), but his source code wouldn't compile in VS2005 because of some strong key error.
Cheers
Jens, Copenhagen.
|
|
|
|
|
|
Hi all
I am having the code which was reading the .xls file like this(code below)
but now in that .xls file,I have two sheets file1 and file2
now how can i go to particular sheet depending upon the input from the user
Excel.Workbook theWorkbook = this.Excelobj.Workbooks.Open(DataClass2.exc_inputFileName, 0, false, 5,
"", "", true, Excel.XlPlatform.xlWindows, "\t", false, false,0, true,false,false);
Excel.Sheets sheets = theWorkbook.Worksheets;
Excel.Worksheet excelWorksheet = (Excel.Worksheet)sheets.get_Item(1);
Excel.Range tempRange = (Excel.Range) excelWorksheet.get_Range("A1","IV1");
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
How to reopen program automatically if program was closed by user, because characteristic of my program is limits user login time duration.
I worry if user use tool that can view processes and stop it.
So i will make my program runs as a virus do (reopen, reopen, and reopen if it was 'End Task')
Thanks for your answer... I more appreciate if you would like to give me a source code :p
:: GreenblitZ ::
jeaffreygilbert@yahoo.com
|
|
|
|
|
You can rewrite your application to run as a Service .
GreenblitZ wrote: So i will make my program runs as a virus do ;P
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
If run as a service means that cannot be stopped..?
How to make it run as a service..?
My teacher said that i have to make remoting application that runs in a service and check my program periodically.. If my program doesn't run, remoting application recall it back.
But the problem is i don't know how to make it
Do you know the best solution for my case detailly...?
Thank you cPallini
:: GreenblitZ ::
jeaffreygilbert@yahoo.com
|
|
|
|
|
When you create a project, you are supposed to select Windows Service instead of Console Application or Console Application as I think you are now doing.
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
with windows forms application override OnFormClosing or OnFormClosed and input Application.Restart();
with console.. no idea
life is study!!!
|
|
|
|
|
Hi,
I've written a command line application that I need to run every couple of minutes. I've used the Windows Task Scheduler as a quick and easy way of calling the application but the problem is that the window is displayed every time the application is called. Is there any way of telling the Windows Task Scheduler not to display the window or can I change my application so it does not show a window as it's executing?
Thanks
|
|
|
|
|
weywe47k37 wrote: Is there any way of telling the Windows Task Scheduler not to display the window
I don't know, but I think it is not possible.
weywe47k37 wrote: or can I change my application so it does not show a window as it's executing?
You can do that, but probably not with a console application.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Rewrite it as a Windows service if it won't need user interaction.
Evil cannot be conquered in the world... It can only be resisted within oneself.
|
|
|
|
|
You can take a look at the Guadagno Task Scheduler, an article here on CodeProject. http://www.codeproject.com/useritems/Guadagno_Task_Scheduler.asp.
This application is a pluggable Task Scheduler that lets you write your own task to schedule. It comes with a RunCommand plug-in that provides the scheduling for Command Line files.
|
|
|
|