|
How can I make a control in C# like
http://www.codeproject.com/treectrl/newtreelistcode.asp .
Is it possible to link with database ? When I change data in database this control will show the right thing in the same time ?
Thx.
|
|
|
|
|
candan wrote:
How can I make a control in C# like
http://www.codeproject.com/treectrl/newtreelistcode.asp
I would suggest to build an ActiveX wrapper on top of this win32 control. Then all what's left to do is drop it onto your form.
Doing owner drawing at the C# level is a mess, and many things are not possible. In fact, you'll end doing the same that some developers have been posting in the C# control section of codeproject : controls that do 100% win32 interop,
candan wrote:
Is it possible to link with database ? When I change data in database this control will show the right thing in the same time ?
That's your application logic.
And I swallow a small raisin.
|
|
|
|
|
I sitting here coding along when I release I need to be able to unsubscribe to an event I just subscribed to. So I go to my books, and none of them talk about it, they show you how to subscribe to an event but not unsubscribe to it. So I do an internet search I get nothing. I do a Code Project search and I get nothing. I have a hard time believing that I am the first person who needed to know how to unsubscribe to an event in C#. In Java it was always straight forward with add and remove events tied to the object want to know about the event.
Well here is the way everyone teaches to subscribe to and event:
<pre lang="cs"> OnEvent += new EventHandler(HandlerMethod);</pre>So I would assume that to unsubscribe you would do the reverse:<br />
<code lang="cs"><pre lang="cs"> OnEvent -= handleToEventHandlerObject;</pre>However since this the EventHandler was created anonymously you do not have a handle/reference to it. <br />
<br />
So my next assumption would be this:<br />
<code lang="cs"><pre lang="cs"> EventHandler handleToEventHandler = new EventHandler(HandlerMethod);
/ ... /
OnEvent += handleToEventHandler;
/ ... /
OnEvent -= handleToEventHandler;</pre>Does this sound right. I have not tried it yet, since I was hoping there was a better way, and also I wanted to do some gripping about C#'s auto-magical delegate system for handling events. Which have created problems, at least for me. Mainly when you want to wrap another object, and provide pass through event handling, you can not. Your wrapper class has to register for the events, and then provide its own delegates for handling it. Also when you want to do something like subscribe and unsubscribe to an event it seams like subscribing is no big deal, but unsubscribing seams like it comes with a little extra (more like annoying) work.<br />
<br />
Just to say it, I think the Java event handling system was far better and more flexible. There was nothing going on auto-magically under the covers. You new there was a Collection holding all the classes who subscribed, and that they are required to have a method signature that you will call when it is thrown. There were standardized add/remove methods that all you have to do is pass the object who subscribed which was 99% of the 'this' keyword. You always hand a handle to the object you used to subscribe to it with.<br />
<br />
Well that’s it with my gripping about C# events. If someone can confirm that above is the correct and only way to subscribe and unsubscribe to an event, or provide a alternative solution.<br />
<br />
:laugh: Thanks for putting up with me. ;P<br />
<br />
Aalst
|
|
|
|
|
|
Thanks, and as hard as it was to believe, and even after reading the related part in the tutorial you linked to, I believe it only because I know how stupid Microsoft can be.
Is anyone with me here on this?
You create an EventHandler object and add it to the an event
to subscribe to this event by means of the += operation. Then
to unsubscribe to this event you have to create another,
unrelated, EventHandler object and subtract it from the event
by means of the -= operation. So you are saying I want to
remove an object that is not there, and it actually removes the
object you intended even though you did not reference this
object at all. (I know it must do it via the method passed as
an argument). This is the most illogical and idiotic thing. If
this is not auto-magical behavior I don't know what is. Man, Microsoft went off the deep end on that one. No wonder no publisher prints this, everyone would think it was a type-o.
As for using event properties to "simulate" pass-through, that looks like more overhead than the way I described. The method I mention also "simulates" pass-through behavior. Regardless, the point is that you cannot actually do any pass-through of event's short of some complicated reflection. All because Microsoft has a few screws loose.
Don't get me wrong, I complain and grip this much about Java and C++ all the time. I am an Equal Opportunity Gripper (EOG).
C# is new, so I have some catching up to do.
Adios,
Aalst
**There is no perfect language
**There is no perfect language
**There is no perfect language
**There is no perfect language
**There is no perfect language
**There is no perfect language
**There is no perfect language
**There is no perfect language
**There is no perfect language
**There is no perfect language
|
|
|
|
|
All they've done is run into the same problem you were griping about in the first place and come up with an easy-to-use (if a little auto-magical) solution, now you're griping about that .
The basic idea is that creating the EventHandler object creates enough information for either += or -= to operate, so it's easy enough to understand how it works.
You're not far wrong about pass-through behavior, but the point is there are several ways to achieve it, depending on the purpose.
For example, another way to achieve it is to make the object containing the event public and "handle" it an extra level up.
ie.
this.MyPassThroughClass.MyEventingClass.MyEvent += new EventHandler...
Paul
|
|
|
|
|
I am not clear on the problem I was gripping about that is the same problem "they" ran into.
Because if a solution is logical, I would only grip about it's extra steps or complexity over a simpler solution. You may be talking about the example I gave in the original post of how I thought it may work, and how I gripped about it have extra steps. If it was the solution it would have been at least a logical solution.
They could have done away with EventHanlders all together, and just have the event use the += operation on the method directly, and -= on the method directly.
public event OnEvent(object, EventArgs);
/ ... /
private void eventHandler(object sender, EventArgs e) { / ... / }
/ ... /
OnEvent += eventHandler;
/ ... /
OnEvent -= eventHandler;
It gains the exact same results with out all the HandlerObjects in the framework, and at least makes more logical sense as to how to use it. I still have not seen anything better and more robust that the way Java handles events.
Regardless its very easy to go around and around on subjects like these. Since nothing we can say can change the fact that the way it is, is the way it is. I easily adjust to stupid and illogical things, all programming languages have there faults.
It is my opinion we are kick the crap out of a dead horse here, I would recommend we just leave it be that no matter how much justification is provided I will not accept the fact that it is the way it is, I will just have to deal with it, and that no matter how much I grip about it and say how much it sucks, and this way or that way is better it will not change the fact that that way or this will will never come to be and that I have to deal with it.
Aalst
|
|
|
|
|
Aalst wrote:
They could have done away with EventHanlders all together, and just have the event use the += operation on the method directly, and -= on the method directly.
But an eventhandler is a delegate which in turn is really a function pointer, thats why u need new EventHandler(MyHandlingfunction) to create a pointer to the function handling the event.
Im not gonna make a big point but, C# is not MS Java (it mite look and feel like it), so there is no point comparing, if you dont like the way C# works use Java or even J# (all of .Net plus most of Java)
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
i am tring to develop an application which can install any type of software on any platform with out user interaction in dot net.
First of all my application will learn all events and messages at least one time then it will perform the task on the network on any computer.
is it possible?
if yes how?
can some one provide the helping metrial and links about that?
r00d0034@yahoo.com
|
|
|
|
|
First of all, make sure your not re-inventing the wheel.
There are currently some commercial products:
InstallAnywhere Zero G (Java based)
JExpress from DeNova (Java based)
And an open source projects:
InstallBase MPI (C & TCL based)
I am sure there are more of these in each area, this is all I could remember quickly.
Also C#/.NET really is not the best language to write cross-platform software yet. Unless you are talking across multiple Windows platforms since Windows is the only OS that has full support for the .NET Framework at this time. There is a UNIX/Linux port in process called the Mono Project. However they have a lot of work to do still before it is finished. I have not heard anything about a MAC .NET Framework yet.
Right now the only true "write once, and run 'almost' anywhere" is Java. C/C++ is also good if you stick to ANSI standards, and keep any platform specific code modular. Then you have pretty much "write once, and compile many times, then run on those compiled platforms". Other than C/C++ or Java there is not popular cross-platform language right now.
So if you have looked at those products and your idea has something they done, either open source versions of the commercial ones, or some newer or better than the existing open source ones. I would say go for it in Java or C/C++.
If not, then you may want to just use one of the ones listed or if you do some searching you may find more that are even better than those.
And remember -- Anything is possible, if you don't give up.
Aalst
|
|
|
|
|
|
imran_rafique wrote:
i am tring to develop an application which can install any type of software on any platform with out user interaction in dot net.
Have fun.
What is the end purpose here? Are you looking to create a marketable product or just for personal use?
If marketable, you have a lot of competition out there. Microsoft's SMS allows a fair amount of remote installing (sit in one console and install all over a network, regardless of OSs). PC-Duo Enterprise (formerly LANutil) has been getting some rave reviews lately as a cheaper, more powerful alternative (I should know, I work for the company that writes it) and will soon be available as an MMC plug-in.
Then there's a LOT of cheap alternatives for smaller companies and individual use (that is, products that do the job you're talking about without the inventory and other functionality offered by PCDE or SMS), several listed by the previous poster.
Also: The first thing we're bearing in mind before considering a .NET conversion is that .NET doesn't work on Win 95, so you've already discounted that option once you look at C#.
Finally, pay a lot of attention to Windows Installer which is doing the job automatically and an increasing number of companies are already picking up on it (we are, despite the fact that it threatens to drive us out of business in the long term!).
Just a few comments for you there, not to discourage you (we're not afraid of healthy competition) but to say "ask yourself the question: why are you doing it? Then research the available products (some of which will be converting to .NET a lot quicker than you can start from scratch) because the effort will be huge and you're not the first to think of it!"
If it's just a personal project, for learning C#, think of something more simple to do first .
Paul
|
|
|
|
|
thanks
let me tell u why i am doing this.i am doing mine final project of MCS.
can u provide the links related to these type of application and available products so that i can study them.
Because i want to do it as fast as possible.
plz provide links if u could?
|
|
|
|
|
You can find PC-Duo Enterprise at
http://www.vector-networks.com[^]
There's a 30-day trial download which includes all sorts of different things, if you look at the product properly you might even find something easier to emulate. Software Distribution is the bit you're looking for though.
I'm sure you can find SMS at Microsoft's site, but I don't know any more than that. You can also find info on Windows Installer there.
Not sure where you'll find the smaller products but I would advise looking for them, there's probably something much more simple to base your ideas on.
Looking at
http://www.installshield.com
http://www.installsite.com
may be useful to you also.
Paul
|
|
|
|
|
thanks
i am doing it as mine final project of MCS?
r00d0034@yahoo.com
|
|
|
|
|
when i use that function (AfxGetInstanceHandle())in managed class i got an exception i do not know how to handle it.
how to sue it in managed vc++ code ?
how to sue it in c# code ?
plz help me.
r00d0034@yahoo.com
|
|
|
|
|
How can I have propertypage or propertysheet in C#?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
I'm trying to change the timeformat to be based upon frames instead of time. I've read everything I could but I don't know how to create a proper GUID to give the mediaSeek.SetTimeFormat(ref System.Guid pFormat) function.
Can anyone help?
the GUID is: TIME_FORMAT_FRAME
|
|
|
|
|
I have a server that accepts a socket connections and accepts authentication requests in a specific protocol. I want to use this for an ASP.NET authentication. How can I make my ASP.NET app maintain a single connection to this auth server and send authentication requests to it?
I mean a COM object does not seem to be the right way anymore. What is the preferred .NET way of implementing this?
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
I have a Control library that works fine when referenced between projects. But I created an install for the control library which deploys the Interop.SQLDMO.dll and SQLServerControls.dll (my output). The SQLDMO.dll (and references) are already installed, yet when I attempt to use or reference the SQLServerControls controls in a project that uses the installed dll it gives me a "file assembly Interop.SQLDMO, or one of its dependencies, was not found." I have validated that everything is there. I have also tried deploying the sqldmo.dll and sqldmo.rll files with the setup but to no avail. If anyone has any ideas I'd love to here em
|
|
|
|
|
Hi,
how to put a Text File into a Assembly as Resource, get this resource from assembly at runtime and write this file back to harddisk ?
.:Greets from Jerry Maguire:.
|
|
|
|
|
Step 1: Embedding a resource into your assembly
If you are using VS.NET simply add the text file to the project and in the properties for the file, set the Build Type to Embedded Resource.
If you are using the command line compiler add the following to your existing command line csc command.
/resource:mytextfile.txt,Name.You.Want.The.File.To.Have.In.The.Assembly.txt
Step 2: Getting a Stream object to your file
In Step 1 you either chose a name for the file or VS.NET created one for you. VS.NET names embedded files with this format: DefaultNamespace.Folder.Filename.ext if you just have the file sitting in the root of the project directory then it will just be DefaultNamespace.Filename.ext
First you need a reference to the Assembly object containing the file; this is usually done by getting a Type object for one of the classes in the assembly.
Assembly asm = typeof(MyClassInAssembly).Assembly;
Now that you have the assembly, you can get a Stream object for the file
Stream stream = asm.GetManifestResourceStream("name of my file in assembly");
Now that you have the stream you can do whatever you want with it; in your case you probably want to open up a FileStream and proceed to read the contents of stream and write them to the new FileStream.
HTH,
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
I want to read Image field from my dataset and create Bitmap object and show it.I use this code:(Northwind database in Access)
int i = myDataGrid.CurrentRowIndex;
byte[] b = (byte[])dataSet11.Tables["Employees"].Rows[i]["Photo"];
if(b.Length > 0)
{
System.IO.MemoryStream stream = new System.IO.MemoryStream(b, true);
stream.Write(b, 0, b.Length);
Bitmap bmp = new Bitmap(stream);
if( bmp.Width > 500 && bmp.Height > 300)
.
.
.
But at the lone Bitmap bmp = new Bitmap(stream); this unhandled error happend:
Invalid parameter used.
Any idea?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
the Stream is an abstract base class. Whenever you want to use a stream, any type of stream i think your supposed to do this.
Stream stream = new MemoryStream(...);
try that.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
Nope.That does not help.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|