471,317 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,317 software developers and data experts.

How to set DataGridTextBox.TabStop ?

I have a DataGrid control with two columns.
I want to prevent the user getting into the first (left) column by the Tab
key, meaning; I need the cells of the left column to be set to TabStop =
fasle.

I found a small sample showing how to that
(http://msdn.microsoft.com/library/de...classtopic.asp)
So I tried:
DataGridTextBoxColumn textBoxColumn =
(DataGridTextBoxColumn)m_dataGrid.TableStyles[0].GridColumnStyles["LeftCloumnName"];
DataGridTextBox gridTextBox = (DataGridTextBox)textBoxColumn.TextBox;
gridTextBox.TabStop = false;

But still the tab gets there.

Can anybody show how can I do that?
-----
Thanks
Sharon
Dec 12 '05 #1
2 5075
Sharon,

The code you showed only prevents the control that is in the column from
getting focus, it won't prevent the column from being selected through tab.
I don't think that is possible with the current grid control.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Sharon" <Sh*****@newsgroups.nospam> wrote in message
news:D5**********************************@microsof t.com...
I have a DataGrid control with two columns.
I want to prevent the user getting into the first (left) column by the Tab
key, meaning; I need the cells of the left column to be set to TabStop =
fasle.

I found a small sample showing how to that
(http://msdn.microsoft.com/library/de...classtopic.asp)
So I tried:
DataGridTextBoxColumn textBoxColumn =
(DataGridTextBoxColumn)m_dataGrid.TableStyles[0].GridColumnStyles["LeftCloumnName"];
DataGridTextBox gridTextBox = (DataGridTextBox)textBoxColumn.TextBox;
gridTextBox.TabStop = false;

But still the tab gets there.

Can anybody show how can I do that?
-----
Thanks
Sharon

Dec 12 '05 #2
Hi Sharon,

Thanks for your post.

To achieve what you want, I think we can do some customize to the code. My
thought is when the first column textbox got focus, just pass the focus to
the second column. Sample code like this:
private void Form1_Load(object sender, System.EventArgs e)
{
DataTable dt=new DataTable();
dt.TableName="test";
dt.Columns.Add(new DataColumn("column1", typeof(int)));
dt.Columns.Add(new DataColumn("column2", typeof(string)));
for(int i=0;i<5;i++)
{
DataRow dr=dt.NewRow();
dr["column1"]=i;
dr["column2"]="item"+ i.ToString();
dt.Rows.Add(dr);
}
this.dataGridTextBoxColumn1.TextBox.Enter+=new EventHandler(TextBox_Enter);
this.dataGrid1.DataSource=dt;
}

private void TextBox_Enter(object sender, EventArgs e)
{
this.dataGrid1.CurrentCell=
new DataGridCell(this.dataGrid1.CurrentCell.RowNumber,
this.dataGrid1.CurrentCell.ColumnNumber+1);
}

This works well on my side. Hope it helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Dec 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Shravan | last post: by
reply views Thread by Jim Witt | last post: by
5 posts views Thread by John Baro | last post: by
2 posts views Thread by Bob Cummings | last post: by
1 post views Thread by Nikhil Patel | last post: by
reply views Thread by David-L. Nadeau | last post: by
1 post views Thread by Jon | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.