TUniQuery not seen as a TDataSet;
Posted: Wed 22 Apr 2015 19:25
I have a form I am trying to pass referenced objects to for processing column widths on a FormShow event. Basically, I iterate through the form with .components, and when it finds them, it grabs the DBGrid, tries to access the dataset name of the TUniQuery that is tied to the DBGrid, and then passes them off to another unit where the procedure cycles through the dbgrid and sets the column widths.
I understand that I had to cast the "TheGrid" variable as a TDBGrid for it to work. The problem I'm having is that when accessing what dataset is used for TheGrid, it errors with
"E2010 Incompatible types:'TUniQuery' and 'TDataSet'"
I need to apologize in advance. I haven't done any coding in 15 years and I'm in a rush here to get this done.
I'm using Delphi XE7 and UniDac 6.1.3
Here is the code-
I understand that I had to cast the "TheGrid" variable as a TDBGrid for it to work. The problem I'm having is that when accessing what dataset is used for TheGrid, it errors with
"E2010 Incompatible types:'TUniQuery' and 'TDataSet'"
I need to apologize in advance. I haven't done any coding in 15 years and I'm in a rush here to get this done.
I'm using Delphi XE7 and UniDac 6.1.3
Here is the code-
Code: Select all
procedure TDistricts.FormShow(Sender: TObject);
var
i: integer;
UQObject: TUniQuery;
TheGrid: TDBGrid;
TheWindow: TForm;
begin
TheWindow := Districts;
for i := 0 to Districts.ComponentCount - 1 do
begin
if Districts.Components[i] is TDBGrid then
begin
TheGrid := (Districts.Components[i])as TDBGrid;
UQObject := TheGrid.DataSource.DataSet;