masked Textbox control in datagridview

2.5k views Asked by At

I have TextboxColumn in Datagridview.usually editing and entering text in this control is cumbersome.I want to make entering text in this control easy.I want following functionality.

  1. Better interface for entering text for example like.

    • Multiline textbox for enterin multiple lines.
    • For Enetring next line user can use ENTER instead of SHIFT+ENTER.
    • and so on..........
  2. Putting Restriction of maximum of 8 lines with each line consist of no more than 80 characters.

currently i am experimenting with this code.

private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
    TextBox txt = e.Control as TextBox;

    if (txt != null)
    {
        txt.Multiline = true;
    }
}

But don't know what to do next.

Thanks.

1

There are 1 answers

2
basti On BEST ANSWER

As far as I know and had to learn, it's not as easy as you think. You have to define your own kind of DataGridViewColumn and DataGridViewCells.

There is an example-description of hosting own Controls in a DataGridView on the MSDN. If you really want to host other Controls in it, try it and ask again if you have questions. On stackoverflow are many people who have done this before.