|
Why does the following line of designer generated code fail ??
this.imgTabImages.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imgTabImages.ImageStream")));
Error:
An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
Additional information: Exception has been thrown by the target of an invocation.
Thanks
|
|
|
|
|
I think this can happen if the image stream that is compiled as a resource is of a newer version than the ImageList win32 control supports. This will typically happen when you have VS.NET using the XP theme styles (by placing a devenv.exe.manifest file in the same dir as devenv.exe) but don't enable XP themes for your application.
This is because version 6 of the common controls writes a different format than the previous versions. I assume it is different because of the support for newer bit-depths.
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
How would I convert a String variable to a byte[] array and back again?
I should say for completeness that the reason why is that I need to save large strings to a SQL server database and read them back again and SQL server "image" field type seems to be the best choice for this since I don't know the lengths that might come in. (they are emails in mime format)
|
|
|
|
|
J Cardinal wrote:
How would I convert a String variable to a byte[] array and back again?
Use the BitConverter Class[^], class members are listed here[^]
-Nick Parker
|
|
|
|
|
Ahhhh! Thank you. :eternal gratitude here:
|
|
|
|
|
Actually, I found that it's much more complicated than that when I tried it. Your method using bitconverter returns a string of text that represents the bytes (i.e. "12-24-fe" etc). What I wanted to do is go from unicode text to byte array then back to unicode text.
I did some scratching around and found that this works although it might not be optimal:
<br />
string sInput="The quick brown fox jumped over the six lazy dogs!";<br />
<br />
byte[] b = Encoding.Unicode.GetBytes(sInput.ToCharArray());<br />
<br />
<br />
Decoder d = Encoding.Unicode.GetDecoder();<br />
<br />
char[] ch= new char[d.GetCharCount(b,0,b.GetLength(0))];<br />
<br />
d.GetChars(b,0,b.GetLength(0),ch,0);<br />
<br />
string sOut=new string(ch);<br />
<br />
|
|
|
|
|
Usually when you're doing something that looks like it's a hackjob...you haven't looked hard enough for something in the Framework:
byte[] myByteArray = DoSomething();
System.Text.UnicodeEncoding encoder = new System.Text.UnicodeEncoding();
string result = encoder.GetString(myByteArray);
Hawaian shirts and shorts work too in Summer.
People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage...
-Anna-Jayne Metcalfe on Paintballing
|
|
|
|
|
|
You should better use text or ntext field instead of image. You won't need any conversion in this case.
Alexandre Kojevnikov
MCP (SQL2K, Win/C#)
Leuven, Belgium
|
|
|
|
|
Hi, is there any way to create a MS Access database (.mdb) file using C# code and ADO.NET? I've done it in the past using ADOX (ADO Extensions). Does anybody know if I still have to use ADOX to do this?
Thanks,
Barry
|
|
|
|
|
Where is the application icon is assigned? So the executable that my program creates, will have the icon that i want.
Thanks,
~Mithat
|
|
|
|
|
Select the project in the Solution Explorer, right-click and select properties, and there is a line for Application Icon. However, if it's a WinForms application the icon shown in the taskbar will be the one given by the main form's Icon property.
Chris Jobson
|
|
|
|
|
When compiling from the command line use the /win32icon command line option to csc.exe.
When building in the IDE set the Appliction Icon option. You can find it by right clicking on your project in the solution explorer, selecting the properties menu item. Appliction Icon is under Common Properties - General.
Cheers,
Peter
Microsoft C# Compiler Dev Lead
|
|
|
|
|
Hi All,
I have list box in one of of my form:
private System.Windows.Forms.ListBox listCampaign;
(InitializeComponent()) function contains those initializations for that list box:
this.listCampaign.Location = new System.Drawing.Point(80, 144);<br />
this.listCampaign.Name = "listCampaign";<br />
this.listCampaign.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;<br />
this.listCampaign.Size = new System.Drawing.Size(168, 69);<br />
this.listCampaign.TabIndex = 1;<br />
this.listCampaign.Visible = false;
And then I add the items to List Box.
listSkillSet.Items.Add("AB");<br />
listSkillSet.Items.Add("AC");<br />
listSkillSet.Items.Add("AD");<br />
listSkillSet.Items.Add("AE");
QUESTION:
Now I have 4 items in my list, I want to show 2 of em already selected.(at the beggining before user chooses - like telling him, we did choose for you already)
I know how to choose one item (highlighted i mean)
as in : listCampaign.SelectedIndex = 0;
But How you select more then one ?
(if I want to Choose (highlight) "AB" and "AC" at the same time
Thanks,
~Mithat
|
|
|
|
|
Assuming that you have set the SelectionMode to MultiSimple or MultiExtended, code similar to the following will work:
listBox1.SelectedIndex = -1;<br />
<br />
for (int i = 1; i < listBox1.Items.Count; i += 2)<br />
listBox1.SelectedItem = listBox1.Items[i];
Chris Jobson
|
|
|
|
|
It worked just fine,
Thank you very much =)
~Mithat
|
|
|
|
|
Hello,
I had written few articles for a major publishing company which unfortunately went out of business. I put together a website to publish these myself. The code samples are all in C#. Please check it out:
http://dotnetuser.www2.dotnetplayground.com/
Thanks
Madhuri
Madhuri Mittal
|
|
|
|
|
Hey Madhuri!
http://dotnetuser.www2.dotnetplayground.com/[^]
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Unknown wrote:
"I love long walks, especialy taken by those that annoy me."
Paraphrased from TMNT:
"Cricket? You have to know what a crumpet is to understand Cricket."
|
|
|
|
|
Hi! I am glad you found me here!
Madhuri Mittal
|
|
|
|
|
Did anyone have the same experience in C# Winform application that you have a form can not be closed? I wonder what would be the possible reason for that?
Thanks.
|
|
|
|
|
Probably catching the Closing event and setting e.Cancel = true .
|
|
|
|
|
There is a known bug where if a control that has focus is removed from the parent form, the form will not be able to close.
The bug may have been more specific in that the control had to be inside of another control, but I can't remember (ie Form A has control B, which has control C; control C has focus and is then removed from B. Now A can't close). I do remember that the example to reproduce the bug had this set-up, but I can't remember if it was a requirement.
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
I want to create a non-visual component that manipulates the form it is dropped onto. Is there a way to access this form from within the component?
Victor
|
|
|
|
|
derive your class from Component , then it can appear in the toolbox, but when dropped into the form, appears in that little bar, like when you add an imagelist object (presuming you have vs.net). and can be accessed from the form.
| Website: http://www.onyeyiri.co.uk
| Sonork: 100.21142 : TheEclypse
| "If a dolar was a chicken would the chicken be evil?"
|
|
|
|
|
not without telling the component what form it is attached to.
this is because most Components can be used from anywhere, not just forms.
that said, I also found this to be a useful idea, so I made a subclass of Component, FormComponent, which i talked about in this blog entry.
This component has a property which points to its Form, when dragged onto a form by a designer. no code required.
|
|
|
|