By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,667 Members | 1,911 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,667 IT Pros & Developers. It's quick & easy.

UserControl in a DataGrid problem

P: n/a
Hi

In my Windows Form application I created a File Browser control that was
derived from System.Windows.Forms.UserControl. It contains a single line text
box and a button. The user can enter a filename in the text box or hit the
browse button, popup the File Open Dialog box, and select a file. The
subsequent selection is placed in the text box. We've seen this type of
control everywhere so I'm not sure why it's not a standard control in the
Framework. But, I digress.

This control is placed in a DataGrid using a column derived from
DataGridColumnStyle. Everything works great except when I’m entering text in
the text box of my File Browser control, hitting Left, Right, Home, or End
moves the current cell in the DataGrid instead of moving the caret in the
text box.

I’m not sure if it’s the DataGrid that’s stealing the key or the UserControl
that’s giving the key to the DataGrid. In other words, I’ve been trying to
hunt this thing down and I can’t find it let alone fix it.

Any help would be appreciated.
Thanks

Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Well, I’ve found that if I derive a class from TextBox and use that in my
UserControl instead of using the stock TextBox, override the ProcessCmdKey()
method, and move the caret myself, I can get this to work correctly.

This seems really sloppy though. I don’t know why the TextBox is not using
the keys and letting the messages bubble up to the grid control.

Anyone have any ideas?
Thanks.
"dlgproc" wrote:
Hi

In my Windows Form application I created a File Browser control that was
derived from System.Windows.Forms.UserControl. It contains a single line text
box and a button. The user can enter a filename in the text box or hit the
browse button, popup the File Open Dialog box, and select a file. The
subsequent selection is placed in the text box. We've seen this type of
control everywhere so I'm not sure why it's not a standard control in the
Framework. But, I digress.

This control is placed in a DataGrid using a column derived from
DataGridColumnStyle. Everything works great except when I’m entering text in
the text box of my File Browser control, hitting Left, Right, Home, or End
moves the current cell in the DataGrid instead of moving the caret in the
text box.

I’m not sure if it’s the DataGrid that’s stealing the key or the UserControl
that’s giving the key to the DataGrid. In other words, I’ve been trying to
hunt this thing down and I can’t find it let alone fix it.

Any help would be appreciated.
Thanks

Nov 16 '05 #2

P: n/a
"=?Utf-8?B?ZGxncHJvYw==?=" <dl*****@discussions.microsoft.com> wrote in message news:<91**********************************@microso ft.com>...
Well, I’ve found that if I derive a class from TextBox and use that in my
UserControl instead of using the stock TextBox, override the ProcessCmdKey()
method, and move the caret myself, I can get this to work correctly.

This seems really sloppy though. I don’t know why the TextBox is not using
the keys and letting the messages bubble up to the grid control.

Anyone have any ideas?
Thanks.
"dlgproc" wrote:
Hi

In my Windows Form application I created a File Browser control that was
derived from System.Windows.Forms.UserControl. It contains a single line text
box and a button. The user can enter a filename in the text box or hit the
browse button, popup the File Open Dialog box, and select a file. The
subsequent selection is placed in the text box. We've seen this type of
control everywhere so I'm not sure why it's not a standard control in the
Framework. But, I digress.

This control is placed in a DataGrid using a column derived from
DataGridColumnStyle. Everything works great except when I’m entering text in
the text box of my File Browser control, hitting Left, Right, Home, or End
moves the current cell in the DataGrid instead of moving the caret in the
text box.

I’m not sure if it’s the DataGrid that’s stealing the key or the UserControl
that’s giving the key to the DataGrid. In other words, I’ve been trying to
hunt this thing down and I can’t find it let alone fix it.

Any help would be appreciated.
Thanks


Hi dlgproc,
I'm expiriencing right now the same problem. So I overwrote the
ProcessCmdKey as you did and that's ok; but what about if you want to
select just a part of text in your derived TextBox by pressing <Shift>
+ <LeftArrow>?
I can't believe I have to overwrite every TextBox behavior!!

Any help appreciated
Thanks a lot
Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.