Click here to Skip to main content
15,559,976 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a WPF window that contains a datagrid and a bunch of TextBox's that should allow the user to edit the data of the selected row. These fields are loaded with the row data from the datagrid in question by code in the Code Behind file.

However, None of the TextBox controls will allow me to even get the cursor into them, it is as if they are disabled, but they are not. I have tried all sorts of things to let me access these.

They are simply placed into individual cells of a grid, so no problems like being hidden by a Textblock etc as can happen in a Datagrid. I have added various Event checks, and these controls do receive Mouseover, MouseDown, Initialized, but do NOT receive KeyDown, GotFocus etc, which are the ones I want them to accept to allow me to edit them.

This is supposed to be the default setting for these Controls ?? but not in my case here.

Here is the XAML for just one of them I have used to test what is going on:

<TextBox x:Name="CustnonoEdit" 
				 Background="{StaticResource Gray3}"
				 Foreground="{StaticResource Black0}"
				Text="{Binding CustNo, UpdateSourceTrigger=LostFocus, Mode=TwoWay}" IsEnabledChanged="CustnonoEdit_IsEnabledChanged" 

It is driving me Mad, can anyone tell me how to make these editable please ?

What I have tried:

Endless tests, see above to try to identify what they do respond to, including testing for IsEnablechanged, but it does not get hit.

See above for info on tests made, and I have searched the web, but mostly, people ask how to DISABLE them, not get the ENABLED as I am trying to do.
Gerry Schmitz 25-Mar-21 13:12pm    
A "default" TextBox is usually all one needs. Start with that, since the one you've shown has been beaten to death; not to mention what might be happening in the code behind. Then start "binding", etc. Your "mental model" of how one edits a row with TextBoxes is the problem: all you need is a "save" button and a "record-level" validation; all your other events are a result of over-thinking the problem.
Member 15074234 26-Mar-21 4:04am    
It is only "beaten to death" because no matter what I do, it remains as a TextBLOCK for all intents and purposes. It is just a simple TEXTBOX control placed in a grid cell on a "window" called by xxx.Show(), and binded to a row of a datagrid. Pretty normal ??

The Binding is straightforward, it is binded to a row from a datagrid that is on a different "Window" which called this window to allow editing of the data, but under my control. It loads that data perfectly correctly on loading.

I do have a save Button to save the changes made to the data in these TEXTBOXES, if only I could get a cursor into them ??

How do I make that more simple ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900