Question 1: how to enter the name, while according to the commodity fuzzy search, and according to the selected name automatically fill in the unit price,
Question 2: if there are two unit price with name, cxGrid1 always only selected the first price, can't choose the second unit price,
Thank you
CodePudding user response:
Look at the official demo \ DevExpress VCL \ ExpressQuantumGrid \ Demos \ Delphi \ GridModeDemo \ GridModeDemoProcedure TGridModeDemoMainForm. TvDataControllerFilterGetValueList (
Sender: TcxFilterCriteria; AItemIndex: Integer;
AValueList: TcxDataFilterValueList);
Var
AColumn: TcxGridDBColumn;
ADataSet: TDataSet;
AProperties: TcxLookupComboBoxProperties;
AValue: Variant;
AIsLookupColumn: Boolean;
The begin
ADataSet:=TcxGridDBTableView (Grid. FocusedView). DataController. The DataSet;
AColumn:=TcxGridDBTableView (Grid. FocusedView). The Columns [AItemIndex];
AIsLookupColumn:=AColumn PropertiesClass=TcxLookupComboBoxProperties;
With GridModeDemoDataDM do
Try
Screen. The Cursor:=crHourGlass;
QryHelper. SQL. The Clear;
QryHelper. SQL. Add (
'the Select DISTINCT + AColumn. DataBinding. FieldName +' From '+
GetTableNameByDataSet (ADataSet));
QryHelper. SQL. Add (
GetSQLCondition (TcxGridDBTableView (Grid. FocusedView), False));
QryHelper. Open;
QryHelper. First;
While not qryHelper. Eof do
The begin
AValue:=qryHelper Fields. [0] Value;
If AIsLookupColumn then
The begin
AProperties:=TcxLookupComboBoxProperties (AColumn. The GetProperties);
ADataSet:=AProperties ListSource. The DataSet;
AValue:=ADataSet. Lookup (
AProperties KeyFieldNames, AValue, AProperties ListFieldNames);
end;
If VarIsNull (AValue) then the Exit;
AValueList. Add (fviValue, qryHelper Fields. [0] Value, AValue, False);
QryHelper. Next;
end;
QryHelper. Close;
The finally
Screen. The Cursor:=crDefault;
end;
end;
CodePudding user response:
Also study in simple cxGrid...CodePudding user response:
A, controls the use of the1, the Form of increased ADOConnection (connect to the database), ADOQuery select the drop-down displays the contents of the table), the DataSource three controls,
Set the corresponding parameters, with respect to its database table,
2, the Form to join cxLookupComboBox controls
Two, set cxLookupComboBox attribute set
(1) the "Properties" Properties, click on the "ListSource", changing DataSource1,
(2) "ListFieldNames said" to display the name of the column, if shows multiple columns, column names use among ";" Space, here, you can set the "name", "unit price" of two or more fields;
(3) "KeyFieldNames" said to return to the column, the result of the
3, set the display attributes of the
Point "ListColumns", appear the following content,
Right margin in three lines, the inside of the corresponding "ListFieldNames" column,
(1) under the "Caption" is displayed when the column headings text,
(2) "HeaderAlignment" said headword alignment,
(3) "Width" said column widths,
Every display column, tx Settings individually,
After set, run, is the following effect.
Of course, your code should show: "name", "price", here only provide display style,
CodePudding user response:
Your code should show: "name", "price", here only provide display style,