|
Hai Frenz,
i want to assosiate different icons for different file programatically using C#. i tried bu creating res file. but still after running the code it is not changing the icons... plzz help me out in this...
Rohitha
|
|
|
|
|
This will depend on the type of file you want to change its icon:
If it's your project's file then you can change that in your project's properties. Once you rebuild you'll see the new icon
If it's another type of file like WAV, AVI, MP#, etc.. You have to associate that file type with the software that contains the icon you wish to use.
Regards
|
|
|
|
|
thnks for reply. here i am changing a file which is not havin an icon by default, also that file is creating by me after the execution of my project. wht i want is, if installed this project in som other system there also it should show the same icon which i am giving. i wanna do it programatically.
Rohitha
|
|
|
|
|
Rohithaa wrote: that file is creating by me after the execution of my project.
If so, go to the properties of your project => Application => Change the icon.
Regards
|
|
|
|
|
Hi
I can't use controls like TextBox or DataGridView in simple Class which i added it from Solution Explorer to my project. It seems that needs System.Windows.Form namespace. My problem is this : Class should inherits from "Form Class" for identifying controls and in this case its behavior converts to Form behavior.
<br />
using System.Windows.Form;<br />
.<br />
public class MyClass : Form<br />
{<br />
}<br />
Is there another way to using controls in class without Inheriting from Form?
Tanx
|
|
|
|
|
You class doesn't need to inherit form Form class to recognize the Controls classes, yet it has to inherit from Form class to display those controls as a windows form, unless you got another way of displaying them.
Simply add a
using System.Windows.Forms;
statement to the top of the file, and all Controls -eg. TextBox, ComboBox, etc...- should be recognizable in your code.
Regards
|
|
|
|
|
Hi,
I have several almost identical datagridviews on a form and I want the cellClick event on each of them to refer to the same event code.
I need to know which datagridview triggered the event. I have each dgv have it's own individual tag and I would like to read the tag of the sending dgv.
I can't discover how to read this information although I am sure it is available.
Any ideas please.
TIA
Glen Harvy
|
|
|
|
|
You can't get it from the sender parameter of the event?
only two letters away from being an asset
|
|
|
|
|
That's what I thought but how do you do this.
I try sender. but only get equals, get, get and tostring?
Glen Harvy
|
|
|
|
|
Ok. What error you got?
Regards,
Satips.
|
|
|
|
|
I don't get an error because I don't know how to get the value in the tag.
Here it is:-
<br />
private void bookingCellClick(object sender, DataGridViewCellEventArgs e)<br />
{<br />
}<br />
Obviously I have a fair bit of code in there which works fine when I hard code the value in the datagridview.tag .
Psuedo code would I guess be "sender.Tag.ToString()" .
Glen Harvy
|
|
|
|
|
Yes. Try with the code and tell or paste the code what you have tried in full so that i can get an idea what u have done.
Hope you got me.
Regards,
Satips.
|
|
|
|
|
You need to cast sender to the actual data type of the control. Since your sender is a DataGridView , you would need something like this:
private void bookingCellClick(object sender, DataGridViewCellEventArgs e)
{
DataGridView dgv = sender as DataGridView;
object tag = dgv.Tag;
}
What, exactly, are you trying to accomplish by accessing the Tag property of the control itself rather than data from the actual cell that was clicked? Pretty much anything you need should be available from the e paramater of the event handler.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Thanks - I knew it should be easy. I tried a couple of variations except "sender as" so I was at least on the right track.
I have several datagridviews that display the status of daily booking periods for tennis courts. Whenever a user clicks on one of the cells, the same action is taken no matter which datagridview is clicked with one exception - the name of the underlying datatable. I've set the variable part of each of the datatables in the datagridviews tag and hence the need to read that value.
I did of course do it the other way and have individual events call the required code and pass the hardcoded datatable value to it but that means duplication and I am trying to learn as I go. Obviously I'm trying to code efficiently as well as successfully
If there is something else to learn from this then I am all ears
Glen Harvy
|
|
|
|
|
Glen Harvy wrote: I tried a couple of variations except "sender as" so I was at least on the right track.
Yes, you were definately on the right track. While this isn't a design pattern in the proper sense of the word, it is fairly common. The nice thing with this cast is that if the cast fails it doesn't throw an exception...the variable is null so you can test for that condition before doing more work.
Glen Harvy wrote: I've set the variable part of each of the datatables in the datagridviews tag and hence the need to read that value.
Given the scenario you are working with, this is probably the best option. I believe you can also get a reference to the underlying datasource from the EventArgs, so you could probably also look at the DataTable name.
Glen Harvy wrote: Obviously I'm trying to code efficiently as well as successfully
That is always the best way to do it, but it seems they don't always go hand-in-hand. Code Project is probably one of the best places to learn as you get a wide variety of experience and solutions, plus the benefit of the articles. Sometimes we can be a bit grouchy, but that's usually because we haven't had morning coffee (or tea) yet.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Thanks for your help on this - much appreciated.
Regards to the cats
Glen Harvy
|
|
|
|
|
Hello everyone,
I have some Buttons in my Windows Applicaton which I would like to add some sort of information for them. I was wondering if it is possible to have a text to be come visiable next to the courser once the courser is hovering over the button. Similar to the one you can have on the toolstrip items?
Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
I'm presuming that you mean you would like a tooltip when you hover over a button or similar control.
Drag a ToolTip control onto the Windows Form you want, then add some code After the InitializeComponent call like this
MyToolTip.SetToolTip(this.mycontrol, "Some Text To Show When Mouse Is Over");
Where MyToolTip is the name given to the tooltip control and mycontrol is the name of the control you want to add a tooltip to.
Then when you hover over the control your tooltip should be shown,
Mark.
|
|
|
|
|
Hello Mark,
Thanx for the info. I have just tried the ToolTip and this is exactly what I was looking for.
Thank you very much and have a great weekend, mate.
Khoramdin
|
|
|
|
|
hi
i want to start an application with hidden window, but how to do ?
|
|
|
|
|
|
I have a c library function that returns a structure. How can i get that structure correctly in c#?
I made an exact copy of the structure in c#, added the attribute [StructLayout(LayoutKind.Sequential)]. What do i then do?
Do I have an IntPtr return type in my dll import function (so i can marshall it) or do I just give the dll import function the structure as return type?
like this
<br />
dllimport...<br />
internal static extern mystruct Function();
or
<br />
dllimport...<br />
internal static extern IntPtr Function(); and then marshall it?
|
|
|
|
|
I think it depends on whether the C function is returning the structure by value or is returning a pointer to a structure. Can you post the C function prototype?
|
|
|
|
|
FSLAPI FSL_EAX_LISTENER_PROPERTIES FSLAPIENTRY fslCreateListenerEnvironment(const char* strData, unsigned int size);
FSL_EAX_LISTENER_PROPERTIES is the structure.
|
|
|
|
|
Ok, well it looks like the structure it returned by value. However, to be on the safe side, if you can find the structure's declaration in its header file, that will tell you for sure. "FSL_EAX_LISTENER_PROPERTIES" looks like a typedef. Sometimes C programmers will typedef a structure pointer. That can disguise whether it is a structure or a pointer to a structure. If you can find its declaration in the header file and post it here, we should be able to nail down for sure whether the function is returning a structure by value or a pointer to a structure.
|
|
|
|