|
Hi all
I am in the process for creating an in house WEB control that can bind to a DataSource - but I can't work out how to. I've deduced that it must be something to do with the TypeConvertor attribute.
I've found this http://morganskinner.dnsalias.net/Articles/DataSource_DataMember.htm [^]which sort of shows what to do but it sort of works but my property doesn't persist properly - but I think that is to do with the example being for a Windows Form control rather than a web control.
Anybody point me in the right direction.
thanks
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
I'll also need to bind to the DataMember and the DataFields (5 of em) once I have managed to do the above.
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
Hi,
Can anyone point me to an example of this as there is none in MSDN and I cant find any others
Without going into many details, I presume I need to create an event foreach type (maybe different event args) as the param gets intrepeted differently in each case. I also assume some kind of In/Out system for receiving it from the unmanaged function and sending it forward as an event trigger.
API:
HSYNC WINAPI SetSync(<br />
DWORD handle,<br />
DWORD type,<br />
QWORD param,<br />
SYNCPROC *proc,<br />
DWORD user<br />
);<br />
<br />
BOOL WINAPI RemoveSync(<br />
DWORD handle,<br />
HSYNC sync<br />
);<br />
<br />
void CALLBACK YourSyncProc(<br />
HSYNC handle,<br />
DWORD channel,
DWORD data<br />
DWORD user<br />
);
If anyone can help, it would be greatly appreciated.
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Each callback becomes a delegate, let's take the example is if we were dealing with EnumThreadProc(HWND hwnd, int lParam), in C# it is :
public delegate bool EnumThreadProc(IntPtr hwnd, IntPtr lParam);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern bool EnumThreadWindows(int threadId, EnumThreadProc pfnEnum, IntPtr lParam);
EnumThreadProc callbackProc = new EnumThreadProc(MyEnumThreadWindowsProc);
EnumThreadWindows(threadId, callbackProc, IntPtr.Zero );
bool MyEnumThreadWindowsProc(IntPtr hwnd, IntPtr lParam)
{
...
}
And I swallow a small raisin.
|
|
|
|
|
Thx Stephane,
That part I think I have understood. The problem is with (un)registering the event from within C# then from within my class I need to activate the unmanaged callback to return to my delegate where some processing gets done, and lastly passing it to C# as an event. Hope it makes sense . Read C# as the class implementing my class.
This is what i have so far, well my logic, but compiler complains
delegate void GetSyncCallBack(IntPtr handle, int channel, int data, int user);
void OnGetSyncCallBack(IntPtr handle, int channel, int data, int user)
{
OnStreamEnd();
}
IntPtr HSYNC;
GetSyncCallBack getSync;
public event EventHandler StreamEnd
{
add
{
getSync += new GetSyncCallBack( OnGetSyncCallBack );
HSYNC = _SetSync(base.Handle, 0, 0, getSync , 0);
}
remove
{
getSync -= new GetSyncCallBack(OnGetSyncCallBack);
_RemoveSync(base.Handle, HSYNC);
}
}
protected virtual void OnStreamEnd()
{
if (StreamEnd != null)
{
StreamEnd(this, null);
}
}
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
I got it, my logic and persistance served my well.
Solution: bold is changes : had to wait 3 min for event to be raised, but it happened when it should
delegate void GetSyncCallBack(IntPtr handle, int channel, int data, int user);
void OnGetSyncCallBack(IntPtr handle, int channel, int data, int user)
{
OnStreamEnd();
}
IntPtr HSYNC;
GetSyncCallBack getSync;
EventHandler streamendstore;
public event EventHandler StreamEnd
{
add
{
streamendstore += value;
getSync += new GetSyncCallBack( OnGetSyncCallBack );
HSYNC = _SetSync(base.Handle, 2, 0, getSync , 0);
}
remove
{
streamendstore -= value;
getSync -= new GetSyncCallBack(OnGetSyncCallBack);
_RemoveSync(base.Handle, HSYNC);
}
}
protected virtual void OnStreamEnd()
{
if( streamendstore != null)streamendstore(this, null);
}
Hope this helps someone in the future
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Great of you lepp I still don't get it but eh that's great
And I swallow a small raisin.
|
|
|
|
|
heheh, I'm not too sure either.....it just looked right and I found an example how to do Event Properties (add/remove) and it showed you had to implement "delegate storage" (what ever thats mean to do, sounds fancy though). The example was actually for implementing multiple events with the same name from different interfaces.
From what I can process (catch StupidyException me) , it works like a normal Property. That's why the compiler originally moaned. So the Event property adds/removes the events to the "store" (any old delegate, my case EventHandler, "store" is actually confusing and is actually THE eventhandler for firing event, not the Property). Now this "store" delegate can be initiated like you would for any event, like i tried.
I think I got it now too , the keyword being Event Property and using that to set/unset the underlying EventHandler for the Event. Unfortunately, I have no clue about C++, so its a bit difficult for me, but I find the 2 languages "similar" in operation.
Hope this provides some more insight
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
plz give me the link for that example i need that one ?
i will be very thank full to u?
r00d0034@yahoo.com
|
|
|
|
|
|
here actually.
And I swallow a small raisin.
|
|
|
|
|
Anyone has any library for lan communication written in c#??I want to use it for my recent project?If you don't have any,i'll still appreciate your advice on how to write a new one.
|
|
|
|
|
look at remoting - System.Runtime.Remoting
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Hi,
we're creating a class scheme which needs to keep the properties instances from the childs classes on the main base class. To do this we're passing the instance of each class once by each child constructor to the main one, I mean:
class child (propertyX A) : base (A) {...}
...this way we pass the instance of one property to the child class when it's instanced so the base class will get it.
It works.
The only problem is that the VS.NET IDE doesn't shows the child window in the design mode, getting an Exception message explaining that there's no instance of the base object or other strange messages like this.
Does anyone knows a solution or a cause?
Thank you in advance,
Edgar
Edgar Berengena Moreno
Software Engineer
Appeyron Research
|
|
|
|
|
Hi,
For that too work you are gonna need a default constructor, in fact for any designer to work, you will need the default constructor. The default constructor is a constructor that takes no arguements. In your case, you could do this:
public DerivedControl():base("some value here")<br />
{<br />
this.var1 = default1;<br />
this.var2 = default2;<br />
}
UPDATE: Note this is only really for designer support. At runtime use your own construtors.
Hope this helps
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
You know I was extremely irritated when I had the same problems earlier. Thanks for the tip...
|
|
|
|
|
I am currently cobbling together an IEnumerable for a class which contains 2 related collections. The problem I have is how to check that the object which is being enumerated does not alter during the enumeration.
What would be nice is......A class to which I can pass any object, and this class will look at all the objects internal data and return an int32 as a hash code. This class could be reused by any collection or object for that matter.
Anyone know of such a class??
Regards,
4space
|
|
|
|
|
Simple things tend to escape me...
Suppose I create a dataset on the main form of my application. This dataset will hold multiple foreground and background colors of my application.
Now when I want to set the color of my text, all I have to do is go to properties and DataBind my ForeColor to a value in the dataset. It's really pretty darn neat! The drop down box will list the dataset and I can pick what value I want.
Now I open up a new form, but unfortunately, my dataset is sitting on the other form. Sure, I can manually type in the code to tie a field to the ForeColor, but this is .NET
So here's the question: How can you create a 'reference' to an object on a different form? I want to be able to use a dataset from one form via the properties on a second form.
In other words, I want a Global DataSet that I can access from any form I create in my project. Is that possible?
Thanks!!!
|
|
|
|
|
|
Does anyone have any information, examples, or ideas about Global Common, Shared memory, File Mapping, etc...? I am trying to share a structure of information between 3 different applications. The shared area needs to be accessed every 100 milliseconds. Any kind of idea will be appreciated.
Thanks,
Tom
|
|
|
|
|
Maybe .Net Remoting will work for you.
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
I have done very little with .Net Remoting. I am under the impression that .Net Remoting simply uses network sockets to pass objects between applications "behind the scenes". I am worried that this will not be fast enough for the updates that I need.
I may be wrong about the above.
Anymore ideas?
Tom
|
|
|
|
|
I am looking at using something more time dedicated other than socket routines. I was hoping to see if anyone has implemented something close to the kernel32.lib routines "CreateFileMapping and MapViewOfFile". I have used "CreateFileMapping and MapViewOfFile" with Visual Basic 6.0 and Visual C++ 6.0 and it worked as I expected it to. Does C# have anything like these routines? Can C# use the kernel32.lib?
|
|
|
|
|
Tom McDaniel wrote:
Can C# use the kernel32.lib?
Yes, via the DllImportAttribute C# can use most, if not all, extern functions from an umanaged dll. See further down the forums, in the last week we had quite alot of talk about it.
Also look at MSDN, NET Framework Developer's Guide, Interoperating with Unmanaged Code Section.
Hope this helps
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Thanks for the answer. This is what I have been looking for. Your help is greatly appreciated.
Tom
|
|
|
|