|
Hi!
By default, the ListView is sorting its items lexicographically, so numbers will not be sorted correctly.
To achive the correct sorting you'll have to write a class implementing IComparer and assign it to the ListView 's ListViewItemSorter property.
You'll get two ListViewItem 's to compare, so you can decide according to which subitem you want to sort, if sorting is to be performed ascending or descending and what to do with numbers or dates.
For example, the core of such a comparer could be something like this:
public int Compare(object x, object y)
{
ListViewItem i1 = x as ListViewItem;
ListViewItem i2 = y as ListViewItem;
try
{
return (int.Parse(i1.SubItems[0].Text) - int.Parse(i2.SubItems[0].Text));
}
catch
{
return 0;
}
} By modifying the SubItem index you can easily sort by different columns or if you use DateTime.Parse instead of int.Parse you can sort your ListView by dates.
Regards,
mav
|
|
|
|
|
I currently use a axWebBrowser control in my C# application to display html. When non-english characters are in the html strings the control displays garbage. Is there a way to configure the control or format the html string so that the characters are displayed correctly?
Any help is much appreciated.
regards,
AD
|
|
|
|
|
Hi,I am using C# to encrypt file.
Here is the code:
public byte[] Encrypt(byte[] sourceObject,string key)
{
MemoryStream msOut = new MemoryStream();
MemoryStream msIn = new MemoryStream();
CryptoStream encryCs;
long lLen;
int nRead, nReadTotal;
byte[] buf = new byte[3];
encryptMethod.Key = GetValidKey(key);
encryptMethod.IV = GetValidIV(key,encryptMethod.IV.Length);
encryCs = new CryptoStream(msOut,encryptMethod.CreateEncryptor(),CryptoStreamMode.Write);
msIn.Write(sourceObject,0,sourceObject.Length);
msIn.Position = 0;
lLen = msIn.Length;
nReadTotal = 0;
while( nReadTotal < lLen )
{
nRead = msIn.Read(buf,0,buf.Length);
encryCs.Write(buf,0,nRead);
nReadTotal += nRead;
}
encryCs.FlushFinalBlock();
encryCs.Close();
return msOut.ToArray();
}
When the size of file is less than 15MB ,the program runs ok.But when the size of file is larger than 15MB,the program will come out the exception of outofMemoryException.
Thank you,
wybstar
|
|
|
|
|
It would be more efficient to eliminate msIn and the loops, and to use a BinaryWriter to write the encrypted data. Something like
BinaryWriter w = new BinaryWriter(encryCs);
w.Write(sourceObject);
return msOut.ToArray();
(flushes and closes removed for clarity).
my blog
|
|
|
|
|
I have modified the code. However ,the program still met the Exception of OutOfException. I want to know whether the .net not support the encryption of big file?
thank you!
|
|
|
|
|
I am using C#.net to make a program to open and close the cd tray.
I tried using System.Runtime.InteropServices namespace. and MCI . ok
The code is truning hell to me and the sdk got me more confusing. I need somebody to tell me exactly what to do .
|
|
|
|
|
hi,
please go through this link.
http://www.artima.com/forums/flat.jsp?forum=76&thread=3997
this may help you out.;)
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
This worked for me:
[DLLImport("winmm.dll")]
extern static int mciSendString(string lpszCommand, int lpszReturnString, int cchReturn, int hwndCallback);
mciSendString("Set cdaudio door open wait", 0, 0, 0);
mciSendString("Set cdaudio door closed wait", 0, 0, 0);
www.troschuetz.de
|
|
|
|
|
Im making a simple media player using managed directx, AudioVideoPlayback. The problem im having is that the video is not playing in the form, it plays in the top left corner of the screen.
here is the code:
Video vid = Video.FromFile(file);
vid.Owner = this;
vid.Play();
im using directx 9.0c summer 2004 update
.net framework 1.1
visual studio 2002, c#
windows XP, sp2
ive tried others code with the same result (MDX sample code). If anybody knows whats going on, Please Help me!
|
|
|
|
|
I got interested in Web Services and found an article at http://www.codeproject.com/cs/webservices/cpwebserviceconsumer.asp; it references http://www.codeproject.com/webservices/latest.asmx, but I get a parser error; is this web service down or has the URL changed? Thanks
Lessons learned from 911:
1. United We Stand.
2. United’s We Fall.
Gulf War Syndrome survivors never have a good day. http://www.vetshelpcenter.com/
|
|
|
|
|
hi,
I found the same question previously (about codeproject webservice). And i didn't seen any usefull thread on that discussion.
Now can you tell me ' how you are trying to use that web service. Is it through IDE or VS commandline ?
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
i want to use exsisting Libs(MFC + C++) in C# projcts.
could any one tell how to achieve this.
--
malotian
|
|
|
|
|
hi,
You need to go through some concept about Com Interoperability.
Lot of article are there in codeproject which will deals the Com Interoperability (Interop).
Try to search.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
i have gone through the interop services and what i have analysed is
---------------------------------------------------------------
.net interop services offer support to integrate c-style dlls into your c#
code i mean managed code,
but not same for unmanaged c++ class libraries. if you want to make calls
into an unmanaged c++ class library, you definitely have to write a
wrapper class, and you have to write it in managed c++.
i think there is no other way out.
----------------------------------------------------------------------
now problem is i have (mfc + c++) libs & dlls only. i dont have the code
with me. so i can't write wrapper classes.
so could u suggest any other way around.
|
|
|
|
|
Try creating a COM object that's calling classes from your dll's.
That way you can easily add a COM reference to your newly-created class and then use this one to access your legacy classes.
Regards,
mav
|
|
|
|
|
In WinForms programming I made 3 Forms.
and the 3 forms have same menu but the menu load all forms each of menu item.
So I think I want to make it does not take more resource when hide a form and show another form.
So I made write down like this...
class Form1
public Form2 form2; Form3 from3;
Form1()
{
form2=new Form2();
form3=new Form3();
}
and like above in another form.
it makes a recursive function and resource take more and more, it can't show main screen. constructor has all resource, it is not I want.
then I copy some code that is using owner but It has some more and more resource when I open file and close file.
I can't use form1.Close it will shut down my program. then I can't get resource when I hide a form.
menu can bring any another form of my program and then hide or close using form.
I must implement it. but I'm a beginner. So I want kind explain.
thanks you for reading.
Image will remind us some feelings and if I can ask someone about a problem, that's not a bad life.
|
|
|
|
|
hi,
The problem is the way you are programming. i am totally confused
Tell me your real requirement. i can help you out.;)
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Hi
Can you try solving your problem using MDI form. Create a MDI form and make your forms as child's of it.
You can make a form as MDI form by setting its IsMdiContainer property to true.
You can make your forms form1, form2, form3 as child forms by setting their MdiParent property to object of your MDI form.
Guess this solve your problem
If you need more help let me know.
Thanks.
|
|
|
|
|
Hi!
I wanted to know how to add code at the OnClick() event of "Next" on acceptance of License Agreement in C# setup and deployment projects. I cant see the source files. I definitely think it is possible, but how and where, please guide me, i am new at this.
Thanks for any help.
-Samir
|
|
|
|
|
Hi,
In a text change event I am loading a list of suburbs based on the user input. When i clear the combobox items I loose the text as well. When I reset the text it calls the change event again and I get a loop happening. How can I clear the items without loosing the text in the box? OR What is a better way than using the text changed that will not be triggered when i write the text back?
Thanks for any help.
|
|
|
|
|
hi,
Better you need to store the selected value to some temporary string variable.
Like string TempString=Combo1.Text;
Then try to clear the items.;)
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
while writting WMI application, i could read many values by means of System.Management namespace.
many examples show how to read the values in Win32_class.
my question is : How to modify the value in Win32_class using System.Management namespace ?
there are some methods which might do this work such as Put(), SetPropertyValue(). But How to use them ?
|
|
|
|
|
I'm using Media Player to play media files, and my problem is getting it to play multiple files where my code does the queuing. I get a medaEnded message, but if I queue another file, it doesn't play. Does anyone have any ideas ?
And anyone who suggests DirectX will be shot. DX9 is an absolute joke, that's why I'm trying to get the core of my app working with Media Player 3 days before I deliver the application.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Heath Stewart wrote:
CharSet=CharSet.Auto
Gotcha, I'll try an be more complete next time. Thanks.
- Nick Parker My Blog | My Articles
|
|
|
|
|
thx for your answer...but i already have the handle of the window...all i want is to get the urls of the address bar in case of the IE or the opened folder in case of he Explorer ...how can i accomplish this?
thx for your time
|
|
|
|