Solved

DBGRID Experts, Please answer this TAB question

Posted on 2000-05-10
6
237 Views
Last Modified: 2010-05-18
I have a dbgrid with approximately 12 fields from one table.  I turn some of these columns.ReadOnly properties to True and then depending on the situation I will turn them back to False.

What my problem is, is that it seems that once my readonly property for a column has been set to True, it never can be tabbed into, even if I set the ReadOnly property back to False.  I can use the arrow keys to get to that column, but Tab will not work.  If the column starts out to be ReadOnly = False then I can tab to it, but like I said as soon as I turn the ReadOnly property to True (this is in code by the way, not design time) I can never tab to it.

Any ideas???
0
Comment
Question by:rwhitaker
  • 3
  • 2
6 Comments
 
LVL 9

Accepted Solution

by:
ITugay earned 100 total points
ID: 2796205
Hi,

There is a sample how to enable all columns in DBGrid for Tab (even read only).  Call this procedure after you change ReadOnly property. The problem is that TDBGrid.TabStops is private propertry. To trick it I use class converting TDrawGrid(DBGrid1). It published there.

procedure TForm1.SpeedButton1Click(Sender: TObject);
var I : integer;
begin
  for I:=0 to DBGrid1.Columns.Count-1 do
  TDrawGrid(DBGrid1).TabStops[I]:=true;
end;

----
Igor.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2796535
? why not set the underlying tfield to readonly instead?
0
 
LVL 9

Expert Comment

by:ITugay
ID: 2796582
To meikl,
I tried it before with the same result. It can't tab if TField.Readonly = true like for Column.Readonly=true. The problem is inside TDBGrid:


unit dbgrids
line 3462.
----
        if TabStops[ACol] then
        begin
          MoveCol(ACol, 0);
          Exit;
        end;
----
it explain why it don't tab.

line 4098
----
procedure TCustomDBGrid.SetColumnAttributes;
var
  I: Integer;
begin
  for I := 0 to FColumns.Count-1 do
  with FColumns[I] do
  begin
    TabStops[I + FIndicatorOffset] := Showing and not ReadOnly and DataLink.Active and
      Assigned(Field) and not (Field.FieldKind = fkCalculated) and not ReadOnlyField(Field);
    ColWidths[I + FIndicatorOffset] := Width;
  end;
  if (dgIndicator in Options) then
    ColWidths[0] := IndicatorWidth;
end;
-----
there you can see how TabStops[I] becam "false" if TField.ReadOnly = true.

------
Cheers,
Igor.
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 27

Expert Comment

by:kretzschmar
ID: 2797024
hi igor, rwhitaker,

try this

//toggle some fields on/off
procedure TForm1.Button1Click(Sender: TObject);
begin
  Table1.Fields[0].ReadOnly := not Table1.Fields[0].ReadOnly;
  Table1.Fields[3].ReadOnly := not Table1.Fields[3].ReadOnly;
  Table1.Fields[4].ReadOnly := not Table1.Fields[4].ReadOnly;
  Table1.Fields[7].ReadOnly := not Table1.Fields[7].ReadOnly;
end;

no problem with the TAB

meikl

0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2797088
sorry,
had misread the question,
igor you're right

meikl
0
 

Author Comment

by:rwhitaker
ID: 2823268
I fixed my problem a little differently than this proposed solution, but it is pretty close to your answer.  Thanks for the help.

What I did was to Reset the readonly properties of the columns back to what they are in design mode and then load the form.  This seems to fix my problem.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question