|
Hello
about this:
[code]
public void OnHandler1(object sender,MyEventArgs e)
[/code]
May someone explain it?
[url]http://www.codeguru.com/csharp/csharp/cs_delegates/eventhandling/[/url]
|
|
|
|
|
Custom EventArgs are used when you need to pass additional information to the subscriber.
You don't use custom event args in cases where you just want to know something happened such as a button click. You know its a button and its been clicked.
You use custom event args if you want more info about the event say if you want to know the background color of the button.
public class MyEventArgs : EventArgs
{
public Color btnColor;
public MyEventArgs(Color color)
{
btnColor = color;
}
}
then when you create;
if (myHandler != null)
myHandler(this, new MyEventArgs(button1.BackColor);
Hope this helps
Mike
Everybody gotta be somebody
|
|
|
|
|
I am trying to create a self updating application. I am sure that you have heard of .Net Reflector.
It is a single exe which has the ability to update it self. Oddly enough it you try to use Reflector on itself it has be ofuscated. So, I can't see what he has done.
Here is how it works.
1. You start up the app and it detects that it needs an update.
2. It appears to shut itself down, download the updated exe and then restarts it.
It you watch the process list you will see that during the update process he spawns (starts...)
a process called tmp6E.exe, which I am guessing does the work.
I have coded up a solution but it doesn't work correctly.
1. I embedded an update.exe program in my main app which does the updating, which works fine.
2. I have tried not using it embedded but I still have the same problem.
How do you start/spawn a process and then shut down the parent (calling app) so that you can
over write it?
|
|
|
|
|
Probably with Process.Start, I'd imagine a call to Procss.Start followed by this.Close() would not close the spawned process.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
That's what I tried first. But it doesn't work.
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1()); <<<---- exception here.
}
I get the following exception
{"Cannot access a disposed object.\r\nObject name: 'Form1'."}
|
|
|
|
|
When do you get this exception ? What do you do to restart Main, or do you just get it when you run the app the second time ? If so, how do you run it ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Okay, I found part of my problem. First let me explain what I am trying to do.
I currently have two exe's.
1. MainApp.exe (has two forms the main form and an update form)
2. Update.exe
When MainApp.exe starts up it downloads a file from one of my web pages (version.txt)
it currently contains 2.0.0.0. I then compare my current version which is 1.0.0.0 and
if the version on the server is larger than my current version I create an instance
of my update form which says "There is an update available do you want to automatically
update?". If you click no I just close the update form and then the main form is shown.
If you click yes, I close the update form and I start the update.exe as a process.
Then I want to exit out of the MainApp.exe and let update.exe download the update
replacing the current out of date one.
My first problem is that I was doing this logic inside the MainForm constructor. If you
attempt to call this.Close() the form has even finished creating itself and thus my problem.
My next problem seems that I am in a continuous loop calling my update form in the MainApp over
and over again.
|
|
|
|
|
The easiest thing to do would be to load your assembly (assemblies) in a shadow cache - this is a little known feature of .NET that copies your assemblies to a temporary directory before executing them. This is done explicitly for the purpose you are asking - software updates - but also for some other, very obscure security reasons that I don't fully understand myself.
At any rate, I first learned of the approach from the Morrison Schartz plugin manager, so you might download their plugin source code and take a look. There are also several articles here on Code Project that use a strikingly similar approach, so they would be good to look at (search for "application auto-update").
For the Morrison Schwartz approach, go here: http://www.ms-inc.net/dotnet.aspx?ProductID=Plugins
|
|
|
|
|
Interesting, thanks I will look into your suggestions.
|
|
|
|
|
Sounds easy but, I am having troubles.
I can't seem to get this to work.
How do you load an exe in the shadow cache?
As in the case of .net Reflector I am trying to solve this
using a single exe.
|
|
|
|
|
hi all i want help plz.i am writing a program and i want the user to select a file.i think the OpenFileDialog control is the key to my problem but i dont know how to use.i have a button and i want the user to click on it and then select the file.any help is appretiated thanks to u all.
Best Wishes
|
|
|
|
|
It's all in the docs. The OpenFileDialog MSDN topic[^] contains an example that is very similar to your situation.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hello, use the following. This open file dialog is for xml files only. Similarly use the file extensions that u use. Use *.* for all files.
OpenFileDialog ofn = new OpenFileDialog();
ofn.Filter = "XML Files (*.xml)|*.xml";
ofn.Title = "Type File";
if (ofn.ShowDialog() == DialogResult.Ok)
{
}
Keshav Kamat
India
|
|
|
|
|
Hi,
I am in the process of building business objects for a database driven application. Most of the entities in the application have a single column primary key (identity value) for each object of its type. For e.g. the Report object, would contain reportId as its primary key column in the database. Most of the entities would contain common Methods like, GetItem, GetItems, Delete, Create and Update.
With the above similarity of CRUD (insert, select, update, delete) operations in my entities, I am following a Attribute based programming model to handle these CRUD operations. I have one common object "BusinessObject". All my business object inherit from this "BusinessObject". The "BusinessObject" would be able to handle all the CRUD operations - GetItem, GetItems, Delete, Create and Update, as long as the child objects inherit from the "BusinessObject" and provide some functionality and methods in them which the "BusinessObject" would need. For e.g., Report class would inherit from BusinessObject. Report class would provide a ConstructItem method that would build the items from the dataset supplied from the BusinessObject.
Protected class BusinessObject
{
Static T GetItem<t>()
{
T instance;
MethodInfo method = T.GetMethod(“ConstructItem”);
Instance = method.invoke(null, dataset) as T;
Return instance;
}
}
Public class Report:BusinessObject
{
Public Report(…)
{}
[Persistent (“paramName”, “DBType.Int32”)]
Int id;
Static Report ConstructItem(Dataset ds)
{
Report r
//Build the report object from the instance
Return r;
}
}
But, I am noticing with this pattern that the all my objects would get tightly coupled with "BusinessObject". The advantage is that there is lot lesser code and the individual objects need not worry about the mundane activities and rather focus on the business calculations. But the disadvantage is, if say a few months down the lane, if we happen to make any updates to the "BusinessObject" then the change would affect all objects which can be a very huge change and might affect all objects. This could become a testing and dev nightmare.
What do you think...
Thanks
|
|
|
|
|
I need code uploade file video same youtup.com
home_alone
|
|
|
|
|
Please don't keep posting the same question.
Also, your question doesn't make sense.
Hopefully any code you produce will be easier to understand.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
I need code upload file video same yuotup.com
|
|
|
|
|
Search for it, and if there is any problem send it here.
|
|
|
|
|
Hello all,
my question is sooo simple
i need to use the event in the datagridview buttons delete and edit
how can i find it?
thanx
|
|
|
|
|
Isn't there an event that gets fired to delete and edit ? Is this a web or windows form ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Is it a windows or a web form ?
also please could you tell if the buttons are within the datagrid, or u want something to be deleted from the datagrid, when the delete and the edit buttons are clicked on the form
Keshav Kamat
India
|
|
|
|
|
i am designing a 3-d choreographer for which i need to hav songs in my music libraray....i want to get the c#code on importing a music file.
parth
|
|
|
|
|
Importing to where ? Do you mean having the file in resources ? Do you mean playing it in your program ? Do you mean adding it to your WMP library ?
You can import WMP as a control and use it to play files.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi guys
i have a custom type object named Person, in my data access layer i fill this object from data adapter and send this object to my presentation layer where there is a datagrid view to display the contents of this object, but i want to make updations based on delete, update and add new actions performed on this object from data grid view , if i am using dataset so i can do that from data adapters update method passig it the changed rows of the data set, but i am not using any data set , so what is most appropriate approach to do that ?
thanks in advance
hello
|
|
|
|
|
You should be calling methods on your Person class, which then call methods in your data layer to insert, update or delete your data.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|