|
Hello,
He meant you should inherit your own NumericTextBox (which has been done about 100 times in the articles)
from Forms.TextBox, and override the OnKeyPress method there.
Or handle the KeyPress event for only the textbox you like to modifie (Like Pete suggested)
yourTextBox.KeyPress+=new KeyPressEventHandler(...);
All the best,
Martin
|
|
|
|
|
It's been suggested to you that you should check the KeyPressEventArgs for the OnKeyPress handler. The code would look like this:
private void txtNumber_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsNumber(e.KeyChar))
e.Handled = true;
} This basically uses the IsNumber member of the char type to determine whether or not a number was pressed. If the user types anything other than a number, the Handled value is set to true. This basically tells the system to ignore that keypress.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks again for replying. I still cant get it right this is the code I used I dont know what to do so I just tried this can you help me again please.
public class NumericTextBox : TextBox
{
private void txtNumber_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsNumber(e.KeyChar))
e.Handled = true;
}
}
where must public class NumericTextBox : TextBox be inserted?
|
|
|
|
|
The code I presented was the event handler for a particular textbox (txtNumber). You would add this code by selecting the textbox in the designer, and then open up the Properties for it. Click the events icon (the one with a little lightning flash on it). And double click the KeyPress item in the property grid. Then you enter the if (...) code inside the auto-generated event handler.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Could anyone please tell me how to change the System.IO.Stream to System.Drawing.Icon?
Example ~
<br />
Dim asm As Assembly = Assembly.LoadFile(assemblyFile)<br />
Dim imgStream As Stream<br />
imgStream = asm.GetManifestResourceStream("MyDLL.MyIcon.ICO")<br />
<br />
Me.Icon = imgStream <<< ERROR: Need to convert the stream to icon...
Thanks in advance.
|
|
|
|
|
Hello,
The Icon class provides a constructor which takes a stream as param!
See the doku[^]
So in C# example:
Icon MyIcon = new Icon(yourStream);
All the best,
Martin
|
|
|
|
|
|
There is a constructor for Icon class which will accept Stream as parameter.
You should be able to do like this
Me.Icon = new Icon(imgStream);
*jaans
|
|
|
|
|
|
I reckon the Icon class might have a constructor which takes a stream.
[can I get my '5' now as well please!]
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"I haven't spoken to my wife now for 48 hours. I don't like to interrupt her.
|
|
|
|
|
I give you mine for the funny idea!
All the best,
Martin
|
|
|
|
|
I gave my '5' to them for two reasons..
#1. the answer helps me a lot.. maybe.. the solution might be so easy or small but I don't know so it is helpful for me..
#2. they are watching codeproject forum all the time.. so I got the answer quickly...
|
|
|
|
|
I wasn't knocking you - honest!!;) It's good that people vote, and better when the answer voted for is quick, easy and importantly, correct.
I just think it is funny when two people post virtually the same answer to the question. I know it gives you, as the OP, more confidence the answer might be correct, but certain people (they know who they are!) do it just to get their post count up.
<edit>I'm digging a hole for myself now...I am not saying that J@@NS did this for the reasons above - the times are too close together. I think I better shut up whilst I am ahead, or at least not too far behind... lt;/edit>
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"I haven't spoken to my wife now for 48 hours. I don't like to interrupt her.
|
|
|
|
|
Hi
I want to create treenode and save those node as an xml file can any one please help.
Mamphekgo
|
|
|
|
|
I am writing a program that consists of several applications, some are client applications, one is the master application, all are standard Windows Forms apps. The clients can all be started seperatly by the user, or the master application starts them automaticly to have the standard user interaction of the client programs and also automated interaction / control with the master program. I would like to do the interaction by simply using public methods and events.
My question is now how do I start the client applications automaticly by the master to have this sort of access? Do I simply create a new instance of the clients main forms? Should I do this in seperate threads to avoid locking up the master program while the clients are working? Or do I have to somehow use Application.Run(), if so how do I do this? Are there any severe pitfalls I am missing?
Help would be appreciated,
Stephan
|
|
|
|
|
stephan.smolek wrote: The clients can all be started seperatly by the user, or the master application starts them automaticly to have the standard user interaction of the client programs and also automated interaction / control with the master program.
The only way to start the other applications is by using the Process class to launch them.
stephan.smolek wrote: also automated interaction / control with the master program
You cannot just expose public methods and expect to be able to call them acrossed AppDomain boundries. You're going to have to learn about .NET Remoting, or Windows Communication Foundation, and setup remoting servers and clients in your applications to handle the communication and you'll also have to carefully design your applications to expose their functionality through various object models, kind of like how Word and Excel do it.
|
|
|
|
|
hi all,
Can anyone knows how to capture the desktop of a remote machine and save it as an image. I have tried and able to capture my same system. But not able to capture the remote machine's desktop.
Thanks and regards
Anez.A
|
|
|
|
|
It cannot be done unless oyu have code running on the remote machine doing the capture and sending the data to your local "server" code.
You may want to Google for and look into "VNCSharp".
|
|
|
|
|
Thank you for ur information.
But, it can be done...
i have seen one application.
Anyway, i'l try to implement .....
|
|
|
|
|
The only possible way that could happen is if you used the built in RemoteDesktop stuff. That's only if it's installed and enabled on the target machine, and you if your credentials work on the target machine for connecting to it.
|
|
|
|
|
Hi all
I want to read a particular node of xml file. For that i am using the code
XmlTextReader reader = new XmlTextReader ("tx1.xml");
while (reader.Read ())
{
if(reader.IsStartElement ())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "jid")
{
str=reader.ReadString();
Lblmsg.Visible=true;
Lblmsg.Text="journal ID <"+ reader.Name+ "> is : "+str;
reader.Read();
break;
}
break;
}
}
but here the problem is it is trying to validate the xml file using the DTD. I dont want to validate it using dtd. Plz help to solve this. what i have to use here. Plz help me thank u
|
|
|
|
|
I have a datatable named EmployeeDT. I am using hastable to store data. I want to to take an employeeID of EmployeeName from data table When i select Employee name in the combobox and add to HashTable.
I am binding data to combobox using this method
foreach(DataRow drow in EmployeeDT.Rows)
{
cboemployee1.Items.Add(drow["Name"].ToString().Replace("\"","\'"));
cboemployee2.Items.Add(drow["Name"].ToString().Replace("\"","\'"));
cboemployee3.Items.Add(drow["Name"].ToString().Replace("\"","\'"));
}
From this code how can i add key to the hash table...
|
|
|
|
|
Hashtable.Add(key, value)
Paul
|
|
|
|
|
No. Write it yourself. This is the best way to find solutions to problems, rather than relying on others.
Have you even read the .NET framework documentation? It shows you how to do it in there.
Paul
|
|
|
|
|
Who were you replying to?
God Bless,
Jason
I am not perfect but I try to be better than those before me.
So those who come after me will be better than I am.
|
|
|
|