>Zakaria,
>I had no luck finding what you were looking for so I tried creating some ustom code. Add this code to the KeyPress event of the textbox control or to your custom textbox usercontrol. It should do what you want it to do. Keep in mind that the code inserts two spaces whenever the TAB key is pressed and not a tab character.
>Hope this helps (if not that is ok too because I had fun writing the code <s>)
Hello Einar,
As far as I see it works ok I have adjusted your code from spacing 2 to 4.
Thank you very much for your time and solution.
Zakaria al Azhar
>
>
>private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
>{
> if (e.KeyChar == '\t')
> {
> int cursorPosition = ((System.Windows.Forms.TextBox) sender).SelectionStart;
> string beforeCursor = ((System.Windows.Forms.TextBox) sender).Text.Substring(0,((System.Windows.Forms.TextBox) sender).SelectionStart);
> string afterCursor = ((System.Windows.Forms.TextBox) sender).Text.Substring(((System.Windows.Forms.TextBox) sender).SelectionStart);
> > ((System.Windows.Forms.TextBox) sender).Text = beforeCursor + " " + afterCursor;
> ((System.Windows.Forms.TextBox) sender).SelectionStart = cursorPosition + 2;
>
> e.Handled = true;
> }
>}
>
>
>Einar
>
>
>
>>Hello All,
>>
>>How to setup the tabspacing to 4 spaces in multiline textboxcontrol instead of the default spacing?
>>
>>TIA.