|
I have an ImageList that I created using Icon (*.ico) files. I would like
to extract an image as an Icon, but casting doesn't work:
Icon test = (Icon)imgList.Images[1];
I know I can access the original .ico file from disk or resource, but since
it was already loaded in an ImageList, I thought this would be an easier
method. Does anyone know if this is possible?
Thanks!
|
|
|
|
|
the Bitmap class has a GetHicon() function. and the Icon class has an FromHandle(IntPtr) static function.
so, maybe something like
Icon test = Icon.FromHandle(GetHicon(imgList.Images[1]));
does it?
:wq
|
|
|
|
|
Thanks! Based on your suggestion, here's what worked:
Icon test = Icon.FromHandle(new Bitmap(imgList.Images[1]).GetHicon());
Thanks again!
Derek
|
|
|
|
|
How to make a combobox uneditable?
Thank you for your solution and attention.
Regards
|
|
|
|
|
How do you want it uneditable? So you can't change the text that is picked from the list?
myComboBox.DropDownStyle = ComboBoxStyle.DropDownList; does that
If you want to make it so that you can't even change which value is selected then set the Enabled property to false.
HTH,
James
Simplicity Rules!
|
|
|
|
|
I have a COM object with 2 interfaces, IClient and IClient2.
Using the object with the first interface is easy, I just add it to my project with "Project/Add Reference", and create it like this:
Client tc = new Client();
Then I get access to all the functions in the IClient interface.
But, I also have e newer interface, IClient2, which implements all methods from IClient and some new ones, but I can't figure out how to use IClient2
Anyone have a good idea?
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
In case you don't get any answers here, the DOTNET mailing list has fielded a TON of questions on COM interop; something I haven't had to do which is why I can't answer your question.
Sorry I don't have a straight-up answer,
James
Simplicity Rules!
|
|
|
|
|
Try this :-
C# program :- Clipboard.SetDataObject(new Bitmap("D:\\nish.bmp"),true);
Now try to paste that into Paint Brush or MS Word or Adobe Photoshop or any other non-.NET app.
It will fail!!!
Why?????????????
Nish
One little CD gone,
Then two CDs gone,
Then 5 more gone,
For a total 7 gones,
If I was a CD R,
I'd wanna cry,
Cause I'd be just a goner,
For a nasty CD burner.
[funny how frustration wakes up the poet in me]
|
|
|
|
|
We've narrowed it down to a problem with Beta 2, poor Nish has to upgrade now and lose VS.NET
James
Simplicity Rules!
|
|
|
|
|
Yeah, this really sucks!!!
Nish
One little CD gone,
Then two CDs gone,
Then 5 more gone,
For a total 7 gones,
If I was a CD R,
I'd wanna cry,
Cause I'd be just a goner,
For a nasty CD burner.
[funny how frustration wakes up the poet in me]
|
|
|
|
|
How would I go about displaying a HTML document inside a windows form? Is there a control that can display HTML text?
|
|
|
|
|
You have to use the web browser activex control that comes with IE. There is an article here that tells how to use the control in your own .NET programs.
James
Simplicity Rules!
|
|
|
|
|
Alternatively you can use the DHTML ActiveX control (DHTMLED.ocx) to use it, simply find the file (or download the latest copy from Microsoft), then add it to your toolbox and add it to your form as a normal control.
The control as lots of methods that you can use to get HTML in to it, e.g. you can directly load a url:
axDHTMLEdit1.LoadURL("http://www.codeproject.com");
or you can access the DOM to add HTML programatically:
axDHTMLEdit1.DOM.body.innerHTML = "<a href=\"http://www.codeproject.com\">The Code Project</a>";
I suggest you download the DHTMLEd SDK from Microsoft which includes documentation for all the properties and methods.
This is a very powerful control but may be a bit of overkill for what you're doing.
|
|
|
|
|
In Java you have the JAI (Java Advanced Imaging) framework for writing advanced imaging applications. Do you have something similar in C# or is it in the works at Redmond for future release?
|
|
|
|
|
Since I'm not a Java programmer I have no idea what JAI includes, but GDI+ (which .NET incorporates) incorporates transparency, alpha blending, gradients, texture brushes, antialiasing, and more.
James
Simplicity Rules!
|
|
|
|
|
Charles Petzold's book on C# is full of information on this topic.
Nick Parker
|
|
|
|
|
Hi All,
I have a text file which will hold some details for my application.
I am now trying to read these details to display them in my application.
I know how to open a file and setup a StreamReader , but how can I make my reader only read from a certain position or even better search for a certain keyword and then read from there?
Thanks,
Gavin
|
|
|
|
|
If its a text file you should probably use a TextReader instead of a StreamReader. You can use the Seek method of the reader to move or position; but if you are looking for a specific thing you will probably have to read through the file until you find what you are looking for.
James
Simplicity Rules!
|
|
|
|
|
I tried using the TextReader but it didn't have the seek option and I couldn't find anything else which was helpful.
I need to pick up 3 different things from this file, but I can't figure out how to read through the file and select a certain thing?
Or is there a better way to do this other than using a static file.
I just need to store some small strings.
Thanks
|
|
|
|
|
Here's some code:
static void Main(string[] args)
{
const int iReadTotal=10;
const int iReadStart=10;
FileStream f = new FileStream ("C:\\test.vbs",System.IO.FileMode.Open, System.IO.FileAccess.Read);
f.Seek(iReadStart,System.IO.SeekOrigin.Current);
StreamReader st = new StreamReader(f);
char[] buffer=new char[iReadTotal];
st.ReadBlock(buffer,0,buffer.Length);
string s="";
for(int i=0;i<buffer.Length;i++)
s+=buffer[i].ToString();
Console.WriteLine(s);
Console.Read();
}
HTH
Cheers,
Simon
"I get paid for my brain and my thinking in several obscure worlds", Olli, The Lounge
|
|
|
|
|
I want to use database in connected mode with DataReader.After I use ExecuteReader() I waana fill DataGrid with it but I can't add row to DataGrid dynamicly or show the table in DataGrid in Connected mode.
OleDbCommand command = new OleDbCommand ( "select * from Tennis", this.myoleDbConnection );
myoleDbConnection.Open ();
OleDbDataReader reader = command.ExecuteReader ( );
while ( reader.Read () )
{
}
reader.Close ();
myoleDbConnection.Close ();
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
I don't think you can fill the datagrid directly, you have to use a datatable at the very least.
James
Simplicity Rules!
|
|
|
|
|
Yes,thats the thing I find out today,So I think when I want use DataReader it is not good idea to use DataGrid and ListView is better option for it.Beacaue for DataGrid I have to use DataSet or DataTable so I have to do one extra operation.Whats your opinion about it?
Thanks
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
[my 2 cents]
Using a listview is a far better option.
Short of prototyping, I don't see a place for large scale databinding in applications.
Cheers,
Simon
"I get paid for my brain and my thinking in several obscure worlds", Olli, The Lounge
|
|
|
|
|
[my 2 cents too]
I understand this using the old databinding control (see VB 6 controls), but with the new ADO.NET model I think things have changed, the combination of Connection, DataAdapter, DataSet and DataGrid should work a lot better.
Anyway, I haven't done any testing yet.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|