Link to home
Start Free TrialLog in
Avatar of iqmedia
iqmedia

asked on

DBGrid in D3 question...

Hi expert(s),

My Q's:
1) How to clear the grey line in DBGrid so when it show the data, it just look plain white?
2) Some of my fields are vary in size such as char(50) etc. How could I resize the columns auto/manually?

Sample:
FieldA     | FieldB               |
1     | Banker               |
2     | Student               |

I dont want it to be like above eventhough the FieldB is char(50).. I want it to be like this: (it can be resize)

Sample:
FieldA     | FieldB     |
1     | Banker     |
2     | Student     |

TQ...

iqmedia
ASKER CERTIFIED SOLUTION
Avatar of Igor UL7AAjr
Igor UL7AAjr
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of iqmedia
iqmedia

ASKER

Hi ITugay,

I found a solution based on your sample code...

procedure Form1.Table1AfterOpen(DataSet: TDataSet);
var
   Max, W, i : integer;
begin
     Max := 0;
     Table1.DisableControls;
     for i := 0 to 5 do // if you have 6 colums fields
     begin
          while not Table1.EOF do
          begin
               W := DBGrid1.Columns[i].Field.DisplayWidth;
               if W > Max then
                  Max := W + 4  // adding 4 char or not will still look good
               else
                   Max := DBGrid1.Columns[i].Width + 4;
               Table1.Next;
          end;
     end;
     Table1.First;
     Table1.EnableControls;
end;

Thanks... I accept your sample code as an answer.

iqmedia
Avatar of iqmedia

ASKER

Thanks again...

iqmedia
Glad to help you,
thanx for points.