|
nah, this code have compile time error :
Error 2 Argument '1': cannot convert from 'System.Windows.Forms.ListView.SelectedListViewItemCollection' to 'int'
however i did a code that speed is better than previous, its taking about 1.5 secs to remove 1200 items :
listViewEx1.BeginUpdate();
ListViewItem[] LVI = new ListViewItem[listViewEx1.SelectedItems.Count];
listViewEx1.SelectedItems.CopyTo(LVI, 0);
for (int a = 0; a < LVI.Length; a++)
LVI[a].Remove();
listViewEx1.EndUpdate();
i like reference type but sometimes it sucks
anyway thanks guys for your responses
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
I see. The ListView.SelectedListViewItemCollection is IEnumerable , but not IEnumerable<ListViewItem> , so it can't be used in the constructor for the list.
listViewEx1.BeginUpdate();
List<ListViewItem> remove = new List<ListViewItem>();
foreach (ListViewItem item in listViewEx1.SelectedItems) remove.Add(item);
foreach (ListViewItem item in remove) item.Remove();
listViewEx1.EndUpdate();
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
buddy i showed you the working code
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Yes, I know. I showed you an alternative along the line of what I suggested earlier.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
ok thanks
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Wat's wrong with listViewEx1.Items.Clear() ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
He want's to remove only the selected items not all of them.
Tut tut, you should read the question
|
|
|
|
|
ah, Clear() will remove all the items, i just want to remove selected items
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Are you using any listview column sorters? If so, you should set it to null before you start removing the items. Once you're done, you can set the sorter back to the original value.
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
no,
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Hi,
I am FTPing programmatically. Everything seems to be fine. But the server response returns (The remote server returned an error: (502) Command not implemented.)
Here is the code snippet.
private void UploadFile(string fileName, string ftpLocation)
{
ftpWebRequest.Method = WebRequestMethods.Ftp.UploadFile;
try
{
FileInfo fileInfo = new FileInfo(fileName);
ftpWebRequest.ContentLength = fileInfo.Length;
FileStream fs = fileInfo.OpenRead();
int bufferSize = 2048;
byte[] buffer = new byte[bufferSize];
int contentLength = fs.Read(buffer, 0, bufferSize);
Stream requestStream = ftpWebRequest.GetRequestStream(); //This is the point of error.
while (contentLength != 0)
{
requestStream.Write(buffer, 0, contentLength);
contentLength = fs.Read(buffer, 0, bufferSize);
}
requestStream.Close();
fs.Close();
}
catch (System.Exception e)
{
}
}
ftpWebRequest is being provided with following...
ftpWebRequest = (FtpWebRequest)FtpWebRequest.Create(new System.Uri(uri));
ftpWebRequest.Credentials = new NetworkCredential(username, password);
ftpWebRequest.EnableSsl = true;
ftpWebRequest.Proxy = null;
ftpWebRequest.KeepAlive = false;
|
|
|
|
|
The error means the server doesn't support the FTP command you sent.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hello;
loader lock error displays each time when i try to record my voice.
plz let me know if some one knows it solution.
|
|
|
|
|
Heed the warning of the Loader Lock MDA - are you loading managed code during initialization of an unmanaged library? Read up more on it here[^] to verify you're not doing anything wrong. If you're not doing anything wrong, the MDA can be disabled in Visual Studio.
|
|
|
|
|
yes i m doing nothing wrong because i just got the dll of directx sound and referenced it.
will u plz let me knw how can i disable the MDA...
|
|
|
|
|
Debug->Exceptions->Managed Debugging Assistants, then uncheck the "LoaderLock" option.
|
|
|
|
|
I'm using the following code to create an instance of a Type:
Activator.CreateInstance(propertyType) // Where propertyType is a Type
This seems to work fine for the majority of types but when I attempt to use it for a string I get the following error:
No parameterless constructor defined for this object.
I've been looking high and low for any examples or documentation on the how to do this and haven't been able to find anything.
Can anybody help and save my sanity?
|
|
|
|
|
|
Activator.Create instantiates an object using its default constructor. As you can see here[^], string has no default constructor. Activator.Create is probably identical to the following:
public object CreateInstance(Type objType) {
ConstructorInfo ci = objType.GetConstructor(Type.EmptyTypes);
if (ci == null)
throw new Exception("No parameterless constructor defined for this object.");
return ci.Invoke(null);
} You will need to have special cases for classes that do not implement a default constructor, either by extending the classes with extension methods (if you have .Net 3.0 or above), or by using a try/catch to catch the exception and instantiate those classes yourself. Hope this helps,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
I guess the reason is that string class has not got public default constructor. You can try either using other overload of CreateInstance or create an instance of StringBuilder class.
|
|
|
|
|
|
Good day
I've been experimenting a bit with the DataGridView, and its memory usage. If you add a high amount of rows to the grid, and then clear it, it apparently won't clear its memory as well. It's as if the rows are still in the memory, but dereferenced. When you populate the grid again, with alot of data, the memory usage keeps on going up, as if he now has two lists of rows. This goes on for a while every time I clear and populate again, until the memory usage gets to a certain amount, then the application freezes for a very short while (some milliseconds) and the memory usage gets reduced back to the normal level of one populated DataGridView.
This is just the GC doing its work, but I didn't know he did it that sporadicly. He also doesn't seem to work in function of time, but in function of total memory usage. He watches how high the memory usage goes, and when it gets to a certain level he finally starts working.
The method GC.Collect() solves this all of course. So now my question is, when you're working with DataGridViews and a high amount of data, is it recommended to actually just always do a GC.Collect after you cleared the grid?
Thanks in advance.
|
|
|
|
|
Jitse wrote: This is just the GC doing its work, but I didn't know he did it that sporadicly. He also doesn't seem to work in function of time, but in function of total memory usage. He watches how high the memory usage goes, and when it gets to a certain level he finally starts working
It is a function of memory usage.
Jitse wrote: The method GC.Collect() solves this all of course. So now my question is, when you're working with DataGridViews and a high amount of data, is it recommended to actually just always do a GC.Collect after you cleared the grid?
Generally GC.Collect() shouldn't be used. You should allow the garbage collector to figure out the optimisation.
I would guess that the slowness is due to a high number of very small objects being cleared up.
|
|
|
|
|
I've got a testing application, that has about 57MB of memory usage with filled DataGridView. Now the GC only starts working at about 200MB. That's quite alot. I'd rather have an application using 57MB all the time, instead of always getting to 200MB before optimization starts to get it back to 57MB.
|
|
|
|
|
The .NET 2.0 Service Pack 1 adds some new APIs to help you control this behavior. Look up System.Runtime.GCSettings class.
|
|
|
|