We have the following case. We need to change a field in a SQL Server database from varchar to nvarchar. After the change, all the dbgrid shows the very wide column. How can we globally adjust the size of this column?
Column Lastname
is very wide:
Let's create a sample table:
CREATE TABLE PATIENT(
ID INT IDENTITY(1,1) PRIMARY KEY NOT NULL,
LastName NVARCHAR(50) NOT NULL
)
GO
INSERT INTO PATIENT VALUES
('Patient1'),
('Patient2'),
('Patient3');
Now let's see the DBGrid
how to show the data:
Your problem is the Sise
of your column (50) here
You can change the DBGrid
column Width
as:
DBGrid1.Columns[1].Width := Value;
also, be sure that dgColumnResize
option of the DBGrid
is enabled (true), in that way you resize the column as needed at runtime.