|
What exactly are you asking? Do you need to store a reference to a delegate in order to remove it from a event later? If so, the answer is "no". So long as the delegate references the same method for the same instance of a class that is already added to an event (which is a MulticastDelegate ), you can "new" up another one like so:
textBox1.TextChanged += new EventHandler(textBox1_TextChanged);
textBox1.TextChanged -= new EventHandler(textBox1_TextChanged); A delegate is like a managed function pointer. So long as the function pointer (the method to which the delegate points) is the same - the same method on the same instance or a static method for a class - the delegate is the same.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I want to create a simple application that opens a window form with controls (mainly text boxes) that feed from a DB. I'm using a DataSet to get the data from the DB but unlike in VB.NET i wasn't able to find the equivalent of:
Me.BindingContext(DataSet11, "tableName").Position
Therefor i am unable to "travel" between rows in the table easily.
The final application is designed to: display, add, delete and modify rows of different tables in the DB and also preforms some algorithms (Using VB.NET is'nt a good solution).
Thank you.
|
|
|
|
|
To navigate data you use a CurrencyManager . It just so happens that the documentation[^] for the CurrencyManager in the .NET Framework SDK has an example of exactly what you're asking.
You get a CurrencyManager for your BindingContext - and all controls to take advantage of navigation must be bound to the same BindingContext , so BindingContext(DataSet11, "tableName") is different from BindingContext(DataSet11.Tables["tableName"], null) - and change the Position .
Be mindful that your comment about this being available in VB.NET is unfounded. The whole point of the CLI (Common Language Infrastructure) - of which .NET is Microsoft's implementation - is to provide a consistent compiled codebase for which any managed language can use (namely assembly modules). This is the purpose of IL (Intermediate Language), to which all managed languages compile. VB.NET and C# compilers may write slightly different IL due to optimization and language features, but IL modules (in assemblies) can be used by either. There are a few rules regarding CLS compliancy, but for the most part everything is the same for most managed languages (JScript.NET is only CLS-compliant, so it doesn't support additional features like unsigned primatives).
So, the Control.BindingContext property is available to C#, VB.NET, Managed C++, Perl .NET, and many others because it's defined in an assembly. BTW, the BCL assemblies (Base Class Library) are primarily written in C# so the fact your using them in a VB.NET application is just further proof of the CLI.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi, friends. I need to build a report with crystal reports with a set of pairs of cells, but I need to do it PROGRAMMING, because I don´t know the number of pairs before running the program (this is calculated each time at runtime). I must be able to draw a 2xn matrix (2 rows and n columns), so I’ve thought to draw 2 little squares and repeat the operation n times (going to the next line if the end of the first one is reached). I’ve been told that all of this is perfectly possible, by accessing to the object model of the report, but I don’t have any single idea about how do thiss!.
It’s very important, since is the only thing I have to do in order to finish my Project, and I have do show it in February.
Thank u everybody, because I know you’re going to give me a hand
|
|
|
|
|
In VC#.net, When Enter Key was been pressed, System warnning sound was been played. How do stop it at programm.
|
|
|
|
|
In Form's KeyDown and KeyPress events,Can do it.
private bool bEnter = false;
private void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
bEnter = false;
if (e.KeyCode == Keys.Enter && this.ActiveControl != fpSpread5)
{
bEnter = true;
}
}
private void Form1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (bEnter)
{
e.Handled = true;
SendKeys.Send("{TAB}");
}
}
|
|
|
|
|
old way use resource file,now how to use xml ?
could you tell me?
|
|
|
|
|
You are right: New way is XML. Use a resx file. Visual Studio has inbuild support. Just set "Use Local Resource" or something like that, in the properties of the Form.
Cheers,
Richard Schneider
|
|
|
|
|
hi Richard,i know how to use resx file.but i dont know how to use xml to achieve my idea , are you know ? please tell me.
|
|
|
|
|
You will have to tell me your idea, before I can help you to achieve it.
I nice thing about a XML resx files is that they are real easy to parse. In theory, an app can be developed to read resx, call google translate and provide you with localised resx files!
Cheers,
Richard Schneider
|
|
|
|
|
ResX files are XML files, and you can even store binary data in a ResX file so long as you encode it in a manner that the ResXResourceReader (or whatever reader you configure) understands, like base64 (which is most common for binary data).
You should read Developing World-Read Applications[^] for a good overview of localizing and globalizing applications, especially the section Resources in Applications[^]. This describes a lot of information with links to classes you should read.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
HI folks,
I am trying to use this freakin old dll. I am new to this so i better ask question one by one.
Starting from struct.
the original struct looks like this:
typedef struct rfreaderstruct RFReader;
struct rfreaderstruct {
HANDLE fh;
OVERLAPPED in_ov;
OVERLAPPED out_ov;
unsigned char buffer[BUFSIZ]; /* Read buffer */
int bufferPoint; /* Number of bytes used from inBuf */
int bufferCount; /* The number of bytes in inBuf */
char nonCommandBuffer[BUFSIZ];
int nonCommandBufferPoint;
int nonCommandBufferEnd;
int mode;
int requestInProgress;
int requestOutProgress;
int pendingWrite;
int pendingRead;
RFMessage rfmsg;
int responseState;
unsigned int responseDataCount;
RFReader *next;
};
Overlapped and RFMessage are just plain struct which i am sure i got it right.
I converted it to this:
[StructLayout( LayoutKind.Sequential )]
internal struct RFReader
{
public const int BUFSIZ = 1000;
internal long fh;
internal OVERLAPPED in_ov;
internal OVERLAPPED out_ov;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=BUFSIZ)]
internal string buffer; /* Read buffer */
internal int bufferPoint; /* Number of bytes used from inBuf */
internal int bufferCount; /* The number of bytes in inBuf */
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=BUFSIZ)]
internal string nonCommandBuffer;
internal int nonCommandBufferPoint;
internal int nonCommandBufferEnd;
internal int mode;
internal int requestInProgress;
internal int requestOutProgress;
internal int pendingWrite;
internal int pendingRead;
internal RFMessage rfmsg;
internal int responseState;
internal uint responseDataCount;
[MarshalAs(UnmanagedType.LPStruct)]
internal RFReader next;
}
I got error on the last line, because this struct is like a linked-list node.
How can i get around this problem?
any help would be greatly appreciated.
|
|
|
|
|
Declare next as IntPtr, and use Marshal.PtrToStructure when you need the structure.
<br />
[StructLayout( LayoutKind.Sequential )] <br />
internal struct RFReader<br />
{<br />
...<br />
...<br />
internal IntPtr next;<br />
}<br />
<br />
RFReader reader = (RFReader)Marshal.PtrToStructure(rfreader.next, typeof(RFReader));<br />
<br />
IntPtr unmanagedBlock = Marshal.AllocHGlobal( Marshal.SizeOf(RFReader) );<br />
Marshal.StructureToPtr(nextReader, unmanagedBlock, true);<br />
rfreader.next = unmanagedBlock;<br />
_________________________________
Vote '1' if you're too lazy for a discussion
|
|
|
|
|
Hi Corinna thanks for the response.
The functions typically look like the following:
RFReader *rfOpenReader( const char *dev, int mode );
void rfCloseReader( RFReader *r );
void rfSetPortBaud( RFReader *reader, int setbaud );
can you show me how to declare it under DllImport?
Thanks,
|
|
|
|
|
frOpenReader:
//un-marshal the RFReader from the IntPtr
[DllImport("anything.dll")]
private static extern IntPtr rfOpenReader(String dev, Int32 mode);
rfCloseReader:
//Both declarations are valid.
//You may try the second one, but without any guarantee.
[DllImport("anything.dll")]
private static extern void rfCloseReader(IntPtr r);
[DllImport("anything.dll")]
private static extern void rfCloseReader(RFReader r);
rfSetPortBaud:
[DllImport("anything.dll")]
private static extern void rfSetPortBaud(IntPtr reader, Int32 setbaud);
[DllImport("anything.dll")]
private static extern void rfSetPortBaut(RFReader reader, Int32 setbaud);
_________________________________
Vote '1' if you're too lazy for a discussion
|
|
|
|
|
Hi Corinna,
Thanks for the help.
I am totally new on this one. I cannot make it to work though.
Once I declare the functions, I don't quite know how to call those functions for now
For example to use rfOpen, in my C# function I write it like this:
public void rfOpenReader ()
{
string READER_DEVICE = "COM9";
reader = (RFReader)Marshal.PtrToStructure(rfOpenReader( READER_DEVICE, RF_MODE_NONBLOCKING ), typeof(RFReader));
}
is this the way to do it?
I got null exception.
Thanks,
|
|
|
|
|
Hi guys
I invoke statusbar.Refresh() method. I think it should call statusbar's "DrawItem" event sequently. But it doesn't. Why? By the way, other controls seem to have similar cases.
Thanks a lot.
vigorous
|
|
|
|
|
Hey Guys
Does anyone know how Microsoft come up with the colors they use in Office 2003 that are consistent with the selected color scheme when using the Windows XP Style buttons/windows.
The only way i've been able to mimic them is to take screen shots and work the colors out from that, not very scientific!
Any ideas greatly appreciated.
Thanks
Tom
|
|
|
|
|
|
Yea, I'm using it to determine the actual colour scheme in use, and changes, but it does not contain the colors that Office Uses. I have a feeling they are hard coded into Office but I want to confirm.
Thanks
Tom
|
|
|
|
|
hi all!
I have a problem but i don't know reason why. My datagrid somtimes display an red X shape in my application. I don't know how to fix. Can you help me for this problem?
Thank you very much!
Đào Ngọc Hào! Hi How Are You?
|
|
|
|
|
The red X gives us the clue that your using the ASP.NET version in a webpage. Your question would be better handled in the ASP.NET Forum, not the C# Forum.
In either case, this usually means that there is a problem with the properties your set in the DataGrid or there is a problem with the DataSet you bound the grid to.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi
I think I've posted it correctly because my problem happened in window application, not in asp.net. Anyway your anwser is good. Do you know something else about my problem ? Or it's the same answer which you've posted.
Finally, Thank you for your helping!
Nguyen Thanh Tu
Đào Ngọc Hào! Hi How Are You?
|
|
|
|
|
Without seeing your code, there's nothing we can tell you about the problem, other than "there's a problem!"
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
It is a memory error. When you do something, For example,
public ArrayList GetResult()
{
ArrayList list = new Arraylist();
list.Add("1");
list.Add("2");
ArrayList list1 = new Arraylist(); list1 = list;
list.Clear();
return list1;
}
In C#, It will tirgger a memory error.
|
|
|
|