|
|
Yep.
Now, I could say I left that as an exercise for the reader?
Or just admit it: I made a mistake - sorry!
Also, to work with your original code it needs to be:
if (e.KeyChar == 13)
{
if (Test1.Text.IndexOfAny(new char[]{'.', '!', '[', ']'}) >= 0)
{
MessageBox.Show("The name can't hold '.', '!', '[]'", "Info", 0, MessageBoxIcon.Error);
return;
}
if (Text1.Text != "")
{
ListBox1.Items.Add(Text1.Text);
}
Text1.Text = "";
}
because I added comma and atsign, and forgot your square brackets as well.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
why test after the unwanted characters have been added to the text? why not check them on entry, i.e. use the KeyDown event and refuse the characters. Or even override the IsInputChar() method.
|
|
|
|
|
Complicated - what happens if the user pastes it in?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Correct, one actually needs both kinds of validation to get immediate feedback.
IMO issuing a bad character message at the end of a line isn't part of a good UI.
|
|
|
|
|
Luc Pattyn wrote: issuing a bad character message at the end of a line isn't part of a good UI.
That throws most of t'interweb in the bin, then...
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
When updating a TreeView, I call BeginUpdate() before adding any nodes. Every now and again, when this is done the thread seems to halt and does not get past the BeginUpdate() call.
The problem is that this happens intermittently, thus sometimes I can spend 30mins trying to reproduce the problem, and it never happens, but other times it happens first attempt.
Has anyone seen this happen? or knows of a problem with BeginUpdate?
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Gareth H wrote: Has anyone seen this happen? or knows of a problem with BeginUpdate?
Any chance of BeginUpdate being called on a different thread?
|
|
|
|
|
No, since i do a If (InvokeRequired) at the top of the method.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Hmm. There's one problem I've seen with InvokeRequired - it returns false if the control's underlying Win32 handle hasn't been created. And that happens if the control hasn't become visible yet.
|
|
|
|
|
The control is visible but not enabled.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Hi Gareth,
I know your post is 3 month ago ... but I have the same problem seen right now.
I can fill the tree a hundred time with no problem and then it happens after the third call.
I didn't found a way to unlock the control - did you ?
Until a better idea is supplied I don't use BeginUpdate()
Regards,
Frank
|
|
|
|
|
Frank,
The problem with my code was that i was doing an:
If (InvokeRequired)
On the main control class, which always returned false when the problem occurred, but the actaul TreeView control was returned true for InvokeRequired.
Thus, the solution was to invoke on the TreeView control. If you need some more info, just say.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Gareth,
thank you for your answer,
I see your problem was different, but I have the problem of a treeview lock when using BeginUpdate / EndUpdate.
My program worked 4 years without error under .NET 1.1 and I got the problems changing to .NET 2.0 SP1 - why ever.
I have nothing running in parallel tasks or threads which could interfere my program.
I left BeginUpdate / EndUpdate unused - no problem any more.
But that leaves no good feeling.
Regards,
Frank
|
|
|
|
|
Friends,
Im new to C#.. Using menustrip...
wants to open other form in main form itself, inspite of opening it in new.
code written in menu button
{
Attendence att = new Attendence();
att.Show();
}
This open form in new window.
|
|
|
|
|
It sounds like you want an MDI application. Set the Main Form's IsMdiContainer property to true, set the child form's MdiParent property to the MainForm before calling Show.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
private void sendSMSToolStripMenuItem1_Click(object sender, EventArgs e)
{
Attendence main = new Attendence();
main.ISPARENT// I DIDNT FIND THIS
main.Show();
}
|
|
|
|
|
MdiParent. Set the Attendence form's MdiParent property to the owner form. Set the owner form's IsMdiContainer property to true
|
|
|
|
|
|
I need to use midiInGetErrorText[^]. I've managed to get it to work by using a StringBuilder with it's Capacity set to UInt16.MaxValue, and passing the StringBuilder to the second parameter and it's Capacity to the third.
public string GetErrorText(Result error)
{
StringBuilder resultBuilder = new StringBuilder();
resultBuilder.Capacity = UInt16.MaxValue;
Functions.midiInGetErrorText((UInt16)error, resultBuilder, (UInt16)resultBuilder.Capacity);
return resultBuilder.ToString();
} Is this the correct way?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
DaveyM69 wrote: Is this the correct way?
I don't think so, setting the capacity actually allocates a char array of that size.
Set a reasonable capacity, then use P/Invoke:
public string GetErrorText(Result error) {
StringBuilder resultBuilder = new StringBuilder(300);
Functions.midiInGetErrorText((UInt16)error, resultBuilder, (UInt16)resultBuilder.Capacity);
return resultBuilder.ToString();
}
BTW: I wouldn't be surprised if the integers needed 32-bit, hence (int) instead of (UInt16)
|
|
|
|
|
Luc Pattyn wrote: I wouldn't be surprised if the integers needed 32-bit
I wondered about that. I've examined several implementations for other winmm functions and some have used int, some uint and some ushort. Is there any definitive way to find out? (I believe all the original constants and prototypes are in mmsys.h - I don't know if that's an original 16 bit C file or a newer 32bit C++ one.)
[Edit] I assumed it was using 16 bit as the midiInProc callback passes a dw that contains 4 bytes - therefore a word should contain 2 [/Edit]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I don't know the finer details of all those fancy integer (and string!) types in C and C++.
Most of the time it says int or DWORD, both being 32-bit.
Be warned about long and char, they differ in .NET versus native.
signed/unsigned does not matter.
To find out, either delve into the header files, or just try. With a pointer in the list, one will work,
the others will fail.
BTW: there is that nice MAXERRORLENGTH constant, that (if not too large) would be the right capacity once you know its value.
|
|
|
|
|
That constant is declared:
#define MAXERRORLENGTH 256 /* max error text length (including NULL) */
but some of the strings returned by the function are longer
(the file is actually MMSystem.h)
255 works fine
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
modified on Saturday, April 25, 2009 9:26 AM
|
|
|
|
|
Found this MSDN page[^] that states what data types to use in the managed world
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|