|
OK, that makes sense if the box were already grounded to the bottom and naurally added items to the top. A regular listbox adds new items to the bottom of the control (which is good) but as the list grows larger than the control, the scroll goes top to bottom. You can scroll down to see the last entry but when you add a new one, it goes back to the top again. Picture a listbox three rows high aligned "far" to create a right alignment:
One
Two
Three
Adding a fourth item to the list should result in:
Two
Three
Four
With the ability to scroll up to see the first entry. This is what I'm trying to do. What's happening now is:
One
Two
Three
With Four below the control which requires scrolling to be visible. I'm trying to create the first scene.
Any ideas on this? Do you know of a 3rd party control that could do this?
Kam Mitchell
|
|
|
|
|
Because i want to send a bitmap object from server to client but Socket.Send method just support byte array so
is there a way to conver bitmap object to byte array and versus ?
|
|
|
|
|
System.Drawing.Image (And System.Drawing.Bitmap) implement ISerializable.
Just serialize your image using a binary serializer.
Grim (aka Toby) MCDBA, MCSD, MCP+SB
SELECT * FROM user WHERE clue IS NOT NULL
GO
(0 row(s) affected)
|
|
|
|
|
You can either serialize or save the image to a MemoryStream . Either way results in the same behavior (ISerializable.GetObjectData saves to a MemoryStream and saves the byte array).
Just using Save does save a little coding, though:
MemoryStream ms = new MemoryStream();
image.Save(ms);
byte[] arr = ms.ToArray();
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi gurus,
Can any one show me how I can add a progress bar in a status bar panel?
Best regards.
Thanks.
There is no spoon.
|
|
|
|
|
The gist of it is that you set one of the StatusBarPanel 's BorderStyle property to StatusBarPanelBorderStyle.None , its Style property to StatusBarPanelStyle.OwnerDraw , and handle the StatusBar.DrawItem event to "draw" that StatusBarPanel . What you actually end up doing is using the StatusBarDrawItemEventArgs passed to you to site (position) a ProgressBar in the area of the StatusBarPanel that you're "drawing".
A quick search on "statusbar progressbar" here on CodeProject yielded a couple good results:
http://www.codeproject.com/info/search.asp?cats=3&cats=5&cats=6&searchkw=statusbar+progressbar[^]
They're in VB.NET, but contain mostly use the BCL (for which the calls are the same for almost any managed language, and the classes/properties/methods/etc. are always the same for any managed language).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
it is not possible to put a standard progress bar in a status panel?
There is no spoon.
|
|
|
|
|
That's exactly what Gary and I told you how to do. You're siting the ProgressBar into a StatusBarPanel . There's really not a lot of difference than throwing a button on a form or something. The only real difference is that the form is the parent of the button and can (if the button sends them) receive window messages from its children. The button is still sited relative to the forum, even in non-.NET frameworks/APIs.
In .NET 2.0, IIRC, there is a more highly advanced status bar being added with a progress bar panel option. Until then, you must either site the ProgressBar into a StatusBar or handle the drawing for a particular StatusBarPanel and draw the progress yourself (it's really quite easily and involves simple math and drawing routines).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
ok, Thanks,
it works the way you said.
I added the ProgressBar in the controls collection of the StatusBar, added a dummy panel to have the progress control in second position.
There is no spoon.
|
|
|
|
|
this is one of many examples here on code project
http://www.codeproject.com/cs/miscctrl/statusbarprogresspanel.asp
Gary
"I invented the internet".
- Al Gore, former U.S. Vice President
|
|
|
|
|
it is not possible to put a standard progress bar in a status panel?
There is no spoon.
|
|
|
|
|
Try this one
Article Link[^]
Gary
"I invented the internet".
- Al Gore, former U.S. Vice President
|
|
|
|
|
i use the class symmetricalgorithm to encrypt, when use the automatically generated key and IV to encrypt the file and stored it in file and later read it from the file to construct a new symmetricalgorithm to decrypt,everyting is ok.when i use a password to generate key and later use the same password to decyrpt,althouge
the key and IV are the same ,i can't decrypt correctly ,what's worse ,an exception throwed,it's CryptographicException with a message of
System.Security.Cryptography.CryptographicException: incorrect data
at System.Security.Cryptography.CryptoAPITransform._DecryptData(IntPtr hKey,Byte[] rgb, Int32 ib, Int32 cb, Boolean fDone)
at System.Security.Cryptography.CryptoAPITransform.TransformFinalBlock(Byte[]
inputBuffer, Int32 inputOffset,Int32 inputCount)
|
|
|
|
|
It could be how you're storing data. A common error is to take the blob (a byte[] ) and write it to a text file. This won't work correctly, since text files store data differently and the bytes will be encoded incorrectly.
Either use an encoding (the common encoding is base64, for which you can use the ToBase64Transform and FromBase64Transform classes) and write the blob to a binary file (using a FileStream , as opposed to a StreamWriter or a StreamReader for example).
The exception you got is consistent with this type of problem. The cipher block or cipher text is not stored correctly and, therefore, will not decrypt when you read it in.
If this doesn't seem to be the case, please provide more information that may be helpful.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thanks for your help!
my encryption steps:
(1) create a symmetricalgothrim instance
(2)a.use automatically generated key and IV to encrypt data and then stored
the key and IV and cipher data(use binarywriter) to a file;
OR
b.use a password and salt value (byte[])to generate key (use PasswordDeriveBytes),and then stored the IV and salt and cipher data in file.
(3) encoding all data with base64
my decryption steps:
(1) decodeing all data with base64
(2) a.read the key and IV to decrypt
OR
b.use the same password&salt to generate the key(the key and IV are same with the previous) to decrypt
but the exception throwed when "b" is executed and everything is ok when a is executed
|
|
|
|
|
First of all, you should not store the key and cipherdata together. Where's the security in that? If nothing else, store them in a separate file (binary file if you keep the blob (byte[] array), or base64-encode it for a text file).
Second, off-hand I don't see anything wrong with your approach. Have you actually done a binary comparison of the generated key from the password and salt to see if they're the same?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
once i use the password derived key ,the exception will be throwed,the code listed below:
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); rng.GetBytes(salt); PasswordDeriveBytes pdb = new PasswordDeriveBytes(password,salt);
byte[] key = pdb.GetBytes(crypter.KeySize/8); crypter.Key = key;
i found that if commented the last sentence,
the program will be ok,but if i use the password derived bytes ,the exception will be throwed ,it is so strange that i don't understand at all~~
|
|
|
|
|
Hi,
Is it possible to make the windows application distributed using IIS. Please sewnd me some info. about the same.
Ravindra
|
|
|
|
|
Depends what you mean. You can always place the exe in an IIS folder and link to it via a normal hyperlink in a webpage or navigate directly to it. There is also the codeBase element of the app config file that can tell were to find assemblies for your app.
|
|
|
|
|
Yes you could by placing the .exe into your web directory however its not the most elegant/safest solution out there. I would recommend using the Updater Application Block pattern for this. This way all of your applications will update from a single central server and all the new updates will be guaranteed to be the ones you have provided because of a cryptographic hash. You can download the code and read about this pattern more here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/updater.asp
|
|
|
|
|
If you strongly name your assemblies, you would already have a cryptographic hash. There is no excuse not to strongly name your assemblies, and it's incredibly simple to do (even more simple that using the UAB). Fusion - the binding manager for the CLR - will even download updated assemblies automatically and cache them in the temporary assembly cache (or TAC, as I call it, though that doesn't seem to be an "official" acronym).
I developed a large N-tier solution using this approach back in 1.0 beta 2 and it works well without the UAB. The UAB does, however, provide you with the capabilities of a disconnected application that updates itself when connected (if any updates are available).
ClickOnce is like a combination of both techniques and we are looking at it for future deployment when released with .NET 2.0 for the only big advantage that the UAB has as I mentioned above: removing the requirement to be always connected (but for a smart application it's pretty much required without a data cache anyway).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have a datatable where I want the top row containing "Time" data to stay at the top when I sort the table by pressing the column headers. The way it is now the "Time" row gets sorted alphabeticly like the other rows.
I have thought of a solution which involves searching for the "Time" row after sorting. When found, remove from place found and insert it at the top. Is there an easier way?
-Atle
|
|
|
|
|
Could you put the "Time" data in the actual column headers instead of the first row of your grid?
If that's not acceptable, you could remove row 0 from your dataset, sort the thing, then insert your time back into the dataset at position 0. It's probably a little faster than searching...
|
|
|
|
|
To put it in the column headers was a good idea. But then I got a new problem. If I import data from a new file (and fill the datatable and set the new table as the grids datasource) and the timedata has changed or now is data for "Depth" or not present at all (the column names has changed), the table is not drawn. I get the row headers, but no columns. I have tried to reset the datatable and set datasources to NULL and a lot of other things to reset the table/grid, but I can't make it work. I can only imort files that have the same timedata as the first file i imported. Or else nothing is drawn. This datagrid/datatable thing is really wierd. It even gets slower and slower to select rows for each file I import.
-Atle
|
|
|
|
|
I have followed the article and project "Customising the header control in a ListView" by Georgi Atanasov, so that I can increase the hight of the header, brilliant. However, if I turn on the XP visual styles with:
Application.EnableVisualStyles();
I no longer get the increase in hight of the header control. Does anyone know how I can use the custom header control of the ListView and also keep the XP visual styles?
|
|
|
|