The powerful form of EHLIB control, believes that friends who have been used have a conference, but DBGRDIEH has not released automatic ways to automatically, it is certainly a bit regret.
However, in DBGRDIEH Optionseh, we can find a DghdblClickOptimizeColWidth option that allows the user to double-click the mouse to automatically adjust the bar width in the width adjustment position of the column.
Since this feature has been implemented, it is not possible to find this method in the method released by DBGRIDEH. After the author tries, the method has been found, as long as it will be released. The specific process is as follows:
First, we find DBGridEh.hpp files and backup, according to dghDblClickOptimizeColWidth clues, we find the full text of the keyword in DBGridEh.pas, the 10514 line, locate the following code fragment: // if (AGridState = gsColSizing) and (dghDblClickOptimizeColWidth in Optionseh) THEN OPTIMIZESELECTEDCOLSWIDTH (Columns [AsizingIndex - IndicatorOffset) // Then it seems that the OptimizeselectedColusWidth (TColumneh * withcolumn) function is what we want!
Look in the header file DBGridEh.hpp in OptimizeSelectedColsWidth function name, find the following statement void __fastcall OptimizeSelectedColsWidth (TColumnEh * WithColumn) line in 1859; it is on the protected domain, we commented diverted, copy, and paste in the public domain The declaration, so OptimizesElectedColsWidth is released.
Because we didn't modify the PAS source section, you can use it without recompilation. Note that this function passes the TColumne's pointer, and we can adjust the Column width of the entire table as long as we traverse DBGRIDEH's Column's COLUMN.
The following is an example:
For (int i = 0; i