|
Thank you for your response Tom. I appreciate it.
I got my code to work, the problem was with my filename, it had a colon in it which was throwing it off.
sasa
|
|
|
|
|
I wish to create a property of a control which is an array of Images, such that I can add, edit and delete images in the VS2005 property window. I've created the property as:
private Image[] _myImages;
public Image[] MyImages
{
get { return _myImages; }
set { _myImages= value; }
}
The property appears in the property window, with a button that brings up the Image Collection Editor (empty, as expected). However, when I press the add button, I get the message "Cannot create an instance of System.Drawing.Image" because it is an abstract class."
If I prepopulate my array with "private Image[] myImages = new Image(3)"
It shows up as an array tree with three (none) images. I can edit each of these (good), but unless I set all of them to something (non null), I am unable to save the form (error is "Code generation for property 'MyImages' failed. Error was: 'Object reference not set to and instance of an object."
I have no trouble includeing a single Image as a property, nor do I have any trouble with an array of strings.
Any Indication as to what I may be doing wrong?
|
|
|
|
|
I'm not certain what to do here, but I have a few tips that might point you in the right direction.
I bet that the key is some attributes on your property that tell Visual Studio what to do with it. I recommend looking at the source code for existing controls that hold arrays or lists. For example, look at the attributes on System.Windows.Forms.ImageList and see how it's being done.
Alternately, to diagnose errors like these, you can attach a VS debugger to Visual Studio, then get the first Visual Studio to throw an error. The debugger should step into your code and show you what piece of your code is throwing an error up to the designer. Read more about this here[^].
|
|
|
|
|
HOW TO CHANG BACKGROUND COLOR IN 1 ROW
q1: I HAVE MANY ITEM 11 ROM BACKGROUND COLOR IS RED BUT I HAVE 2 ROW TO CHANG
BACKGROUND ONLY HOW?
q2: HOW TO HIGHLIGHT LIST VIEW IN EACH ROW
thanks
|
|
|
|
|
First of all, stop writing in all caps. That's the quivalent of shouting on the web. Don't do it.
Secondly, I realize English may not be your first language, but in any event, your sentences are so broken it's difficult to understand what you're asking. Perhaps you could more carefully craft your question in English, or post on a board of your native tongue.
To answer your questions, I will try my best to understand what you're asking.
abcomp01 wrote: q1: I HAVE MANY ITEM 11 ROM BACKGROUND COLOR IS RED BUT I HAVE 2 ROW TO CHANG
BACKGROUND ONLY HOW?
It sounds like you're asking how to change the background color of an item. What kind of item? I assume from your 2nd question that you're wondering how to change the back color of a Windows Forms ListViewItem. If so, look at ListViewItem.BackColor property.
abcomp01 wrote: HOW TO HIGHLIGHT LIST VIEW IN EACH ROW
I don't know what you mean by this. Can you clarify?
|
|
|
|
|
now i know listView1.Items[0].BackColor = Color.Red;
.......... srry u should before answer
"" q1: I HAVE MANY ITEM 11 ROM BACKGROUND COLOR IS RED BUT I HAVE 2 ROW TO CHANG
BACKGROUND ONLY HOW? ""
|
|
|
|
|
BackColor = myListView.BackColor?
Once again, I have no idea what you're asking.
|
|
|
|
|
I recently reinstalled visual studio, but now when i try to add a class (project -> add class) instead of having a class, i have an option to add an interface...and instead of windows form i have inherited form.
Is there a way to add the form and class templates?
|
|
|
|
|
have you tried the /resetsettings switch when running devenv?
|
|
|
|
|
um, i don't really know how to do that =[
and it's a fresh installation so i don't know if resetting settings would help, it's already it's default
|
|
|
|
|
Start up Visual Studio by the command line, passing /resetSettings as a command line argument.
If you don't know how to start applications with command line arguments, you should learn how to do that before continuing programming.
Does right-click on your project -> New Item... -> Class work?
|
|
|
|
|
i did resetsettings and it didn't work, and when i right click-add item on my project i don't have a class but when i do the same on the solution i do...=\
|
|
|
|
|
Maybe your project's type, intentional or not, is such that it can not hold classes.
sharpiesharpie wrote: when i do the same on the solution i do...=
I doubt that, the only thing a solution can hold is projects.
Did you have disk problems ? Did you edit solution/project files manually ?
I suggest you try again, at least with a new project inside the existing solution;
better yet with a new solution and new project.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
obviously...i said it's been that way since i installed VS (after formatting) =/
|
|
|
|
|
I don't know why I'm having some many issues with this, but some help would be appreciated. I'm working on a unit test. I need to get my image saved to a string and placed in my XML document. Below is the code that almost works... The part that doesn't work is when I write the byte array of the image contents to the String Builder. Only part of it comes out, then the StringBuilder object just quits working and doesn't write any more after.
StringBuilder xmlString = new StringBuilder();
xmlString.AppendLine("<TranslationRoot>");
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(25, 25);
for (int i = 0; i < 25; i++)
{
for (int j = 0; j < 25; j++)
{
Color pixelColor = bitmap.GetPixel(i, j);
int r = pixelColor.R;
int b = pixelColor.B;
Color newColor = Color.FromArgb(r, 0, b);
bitmap.SetPixel(i, j, newColor);
}
}
MemoryStream gifStream = new MemoryStream();
bitmap.Save(gifStream, System.Drawing.Imaging.ImageFormat.Gif);
System.Text.UnicodeEncoding encoding = new UnicodeEncoding();
byte[] gifByte = new byte[gifStream.Length];
gifStream.Position = 0;
gifStream.Read(gifByte, 0, gifByte.Length);
xmlString.Append(" <Value><![CDATA[" + encoding.GetString(gifByte) + "]]></Value>");
The last line of the XML looks like:
<Value><![CDATA[䥇㡆愹÷}
So after that last append, any additional appends just don't work. No error is thrown. So any help is appreciated.
Thanks!
Hogan
|
|
|
|
|
Hi,
XML is supposed to be readable text, and structured as well.
Inserfting a lot of arbitrary bytes will not preserve these characteristics;
some of your bytes will happen to be < or > signs, others will be negative, etc.
So you need a way to encode (and later decode) arbitrary bytes into printable characters
or strings.
A popular way of doing that is with Convert.ToBase64String(); this will generate a string
from a limited set of 64 characters; it generates one character for every 6-bits of
input data, hence it expands the data by 8/6 in size. That's the price to pay to keep
it readable/printable, and XML-compatible.
Decoding that string is done with Convert.FromBase64String().
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc,
Thanks for your reply. That is exactly what I needed to do. Its the second time you have replied to my help and I sincerely thank you!
Hogan
|
|
|
|
|
You're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Ok, listen here. I have an application which code I cannot access. It has an Inactivity timer which is running. If I dont touch the pc for more than a certain ammount of time a message will show and log me out. Id like to know how to stop this by writing some code to make it look as though someone is active in windows when really they are not.
The only thing i can think of is creating a timer and sending some sort of message to windows to make it look as though we are active.
Thanks in Advance.
www.codewash.com
|
|
|
|
|
It depends exactly how it defines activity. Theres plenty of apps around if you search for something like "mouse mover".
|
|
|
|
|
|
Thanks Dinobot_Slag, we are on the right track. I need to figure out now how to send like a wm message or somthing so that the hooks being used by the application will see it and believe we are active.
www.codewash.com
|
|
|
|
|
Hi I'm looking to my queries to an Access database in C# that is password protected and I am having difficulties. The password is 13 characters long and contains capital, lowercase, symbols (#$%^) and numbers. My connection string looks like this:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\file.mdb;User ID=admin;Password=P@$$w0rD";
When I call:
OleDbConnection myConnection = new OleDbConnection(connectionString);<br />
myConnection.Open();
The program crashes with an unhandled exception of type 'System.Data.OleDb.OleDbException in system.data.dll.
I did some research and it says that C# handles special characters in a way that isn't compatible with some access databases. I'm not sure if $%^ are special characters, or if that means just unicode.
Does anyone know where I'm slipping up or how to fix this? Any advice would be appreciated.
|
|
|
|
|
Ken Mazaika wrote: The program crashes with an unhandled exception of type 'System.Data.OleDb.OleDbException in system.data.dll.
And what did the exception message say? That is quite important becuase there are many reasons it might throw an exception of that type.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
The message box said "Microsoft Development Environment" in the titlebar, the words "An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll" and Break, Continue, Ignore (disabled), and Help buttons.
The debugger highlights the line immediately following the Open(), which happens to be return true;
thanks,
-Ken
|
|
|
|