Hi Derek,
Thank you for that great advice. It works !
Your suggestion to check the currentCellChanged event worked great. Also, I
applied the same code to the GotFocus event in the case when you click on
the DataGrid for the first time.
Here's the code I used:
Dim vCurRow As Integer = DataGrid.CurrentCell.RowNumber
DataGrid.CurrentCell = New DataGridCell(vCurRow, 1)
However - I have a "New" problem, and I can't seem to find the solution no
matter how bad I bang my head over here...
When I try to backTab, it doesn't go to the previous row. Now I know that I
would have to check for the BackTab key and apply the same logic above
except the row could be the vCurRow - 1.
But... I tried using KeyPress, and KeyDown events and I can't trap the
BackTab key.
Would anyone have any suggestions as to how I can trap the BackTab Key
(I checked the VS help and it says to do this :
"Certain keys, such as the TAB, RETURN, ESCAPE, and arrow keys are handled
by controls automatically. In order to have these keys raise the KeyDown
event, you must override the IsInputKey method in each control on your form.
The code for the override of the IsInputKey would need to determine if one
of the special keys is pressed and return a value of true. ")
I am wondering if there's an easier way to trap the BackTab key than what's
shown in the help.
Again your help is greatly appreciated.
Thank you,
Paul.
"Derek Harmon" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "PAUL GROSSMAN" <(E-Mail Removed)> wrote in message
> news:CJzRd.25101$ya6.12064@trndny01...
>> I want to make one of the columns un-editable. I was able to do that by
>> setting
>> the .dsName.Tables("TblName").Columns("ColName").ReadOnly = True
>
> Paul,
>
> I think I hear that you're saying you set ReadOnly on the DataColumn.
> Have
> you tried setting ReadOnly on the DataGridColumnStyle?
>
>
> Me.dataGrid1.TableStyles("TblName").GridColumnStyles("ColName").ReadOnly =
> True
>
> The DataColumn represents the "model" of the data, whereas the DataGrid-
> ColumnStyle represents the "view" of that data. It might be more
> on-target
> to modify the view's characteristics instead of the model's.
>
> Another thing you might try is to handle the CurrentCellChanged event
> to check Me.dataGrid1.CurrentCell.ColumnNumber and change it back
> whenever the end user selects a column you don't wish to receive focus.
>
>> That made it so you can't change the value in the column, but you're
>> still tabbing into the column (despite the fact you can't change it).
>
> As an aside, if you're writing an application that needs to be Accessible
> then the effect of a user's TAB key shifting focus to a non-editable cell
> isn't necessarily a bad thing. Some screen readers (for the blind) use
> speech-synthesis to recite the contents of cells that receive focus. If
> you must workaround this problem, it may limit the application's
> Accessibility.
>
>
> Derek Harmon
>
|