Home > Back-end >  For beginners, thank you
For beginners, thank you

Time:09-15

MDBGrid. Columns [I]. Field. The Tag, the statement of the return value is the width of the column content? If not, what is that? Thank you very much!

CodePudding user response:

DBGrid1. Columns [I]. Width

CodePudding user response:

The tag is a custom value, you want to define what is what

CodePudding user response:

refer to the second floor leavesguth response:
tag is a custom value, what you want to define what is



MDBGrid. Columns [I]. Width:=Max (mDBGrid. Columns [I] Field. The Tag,
MDBGrid. Canvas. TextWidth (mDBGrid Columns [I] Title. The Caption)) + mOffset
The original sentence is so of, take the width of the column headers and the width of the column column mDBGrid. Columns [I] the maximum Field. The Tag + mOffset

CodePudding user response:

reference qq_41092628 reply: 3/f
Quote: refer to the second floor leavesguth response:

The tag is a custom value, you what you want to define what is



MDBGrid. Columns [I]. Width:=Max (mDBGrid. Columns [I] Field. The Tag,
MDBGrid. Canvas. TextWidth (mDBGrid Columns [I] Title. The Caption)) + mOffset
The original sentence is so of, take the width of the column headers and the width of the column column mDBGrid. Columns [I] the maximum Field. The Tag + mOffset


MDBGrid. Columns [I]. Field. What is the value of the Tag

CodePudding user response:

reference 4 floor qq_41092628 response:
mDBGrid. Columns [I] Width=Max (mDBGrid. Columns [I] Field. The Tag,
MDBGrid. Canvas. TextWidth (mDBGrid Columns [I] Title. The Caption)) + mOffset
The original sentence is so of, take the width of the column headers and the width of the column column mDBGrid. Columns [I] the maximum Field. The Tag + mOffset
MDBGrid. Columns [I]. Field. What is the value of the Tag

The width of the tag should be a defined value, you look again, should rest have assignment, or write directly in the attribute value,
Max values inside two values of maximum value, the definition of the tag value and the width of the caption who and who, add a custom value mOffset,
Like to get a little complicated, don't know what's the point,

CodePudding user response:

reference 5 floor leavesguth reply:
Quote: refer to 4th floor qq_41092628 response:

MDBGrid. Columns [I]. Width:=Max (mDBGrid. Columns [I] Field. The Tag,
MDBGrid. Canvas. TextWidth (mDBGrid Columns [I] Title. The Caption)) + mOffset
The original sentence is so of, take the width of the column headers and the width of the column column mDBGrid. Columns [I] the maximum Field. The Tag + mOffset
MDBGrid. Columns [I]. Field. What is the value of the Tag

The width of the tag should be a defined value, you look again, should rest have assignment, or write directly in the attribute value,
Max values inside two values of maximum value, the definition of the tag value and the width of the caption who and who, add a custom value mOffset,
Like to get a little complicated, don't know what it means,


The function DBGridAutoSize (mDBGrid: TDBGrid; MOffset: Integer=5) : Boolean;
{return data grid automatically adapt to the width of success}
Var
I: Integer;
The begin
Result:=False;
If not Assigned (mDBGrid) then the Exit;
If not Assigned (mDBGrid. The DataSource) then the Exit;
If not Assigned (mDBGrid. The DataSource. The DataSet) then the Exit;
If not mDBGrid. The DataSource. The DataSet. The Active then the Exit;
For I:=0 to mDBGrid. Columns. Do the Count - 1
The begin
If not mDBGrid. Columns [I]. Visible then Continue;
If Assigned (mDBGrid Columns [I] Field) then
MDBGrid. Columns [I]. Width:=Max (mDBGrid. Columns [I] Field. The Tag,
MDBGrid. Canvas. TextWidth (mDBGrid Columns [I] Title. The Caption)) + mOffset
The else
MDBGrid. Columns [I]. Width:=
MDBGrid. Canvas. TextWidth (mDBGrid Columns [I] Title. The Caption) + mOffset;
MDBGrid. Refresh;
The end;
Result:=True;
The end;

CodePudding user response:

This is just a function, a part of the application,
If I understand well, the tag must be assigned elsewhere, otherwise he will always be a value 0,
You do a test to know:
ShowMessage (DBGrid1 columns [1]. The Field. The Tag. The ToString);

CodePudding user response:

Like mOffset: Integer=5, the tag to a value, must be assigned to it, you can find all the code to see,
I don't like very complicated code, too, can be simple is simple:
//width adaptive
Eh. AutoFitColWidths:=False;
For: l=0 to eh. Columns. Do the Count - 1
The begin
Eh. The Columns [l]. OptimizeWidth;
Eh. The Columns [l]. Alignment:=taCenter;
The end;
The result is right also, of course, this is DBGRIDEH form,

CodePudding user response:

Automatically whether the width of the definition of the maximum width of the text according to the list? If so, the use of the function should be in the text after the load to call again

CodePudding user response:

The Tag as custom index commonly used,

CodePudding user response:

Refer to this: https://blog.csdn.net/danfeng906/article/details/43235439

CodePudding user response:

Control has a Tag, it is provided to user programming, when using a parameter value, it is agreed with the controls,
The default value is 0.
For example:
Top value
Withe value
The serial number, waiting for
A ten-day words, it's programming user, stored in the control of a parameter values,
  • Related