Hi all!
I have a question :
I want to prevent the ' keyboard to textbox, please help me!

(Sorry, I don't know how to call ' keyboard, it is below " )
Thanks

Double click the textbox to create the event "textbox_TextChanged"
then type in this code:

private void textbox_TextChanged(object sender, EventArgs e)
{
    textbox.Text = textbox.Text.Replace("'", "");
}

this will replace any instances of ' found within the textbox.

However, due to the cursor going back to the beggining of the textbox, i would personally create an event for textbox_LostFocus and put this code in there.

I hope this helps

Alternatively, and this would be my preferred option, you can use the KeyPress event to disable that key entirely:

private void textbox_KeyPress(object sender, KeyPressEventArgs e)
{
    if (e.KeyChar == '\'')
        e.Handled = true;
}
commented: The better option by far. +4

thanks for that alternative deceptikon. This will come in handy

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.