Hi!
I followed this Delphi sample for accessing columns of a TIWDBGrid using C++Builder, but it does not work.
Below is my code:
I am having the error message "Argument out of range" beginning from the first line and for each line.
Any idea of how to get rid of this error?
I followed this Delphi sample for accessing columns of a TIWDBGrid using C++Builder, but it does not work.
Below is my code:
Code:
__fastcall TForm1::TForm1(TComponent* Owner) : TFrame(Owner)
{//
TRESTClient *REST1Client = new TRESTClient(this);
TRESTRequest *REST1Request = new TRESTRequest(this);
TRESTResponse *REST1Response = new TRESTResponse(this);
TClientDataSet *ClientDataSet1 = new TClientDataSet(this);
TRESTResponseDataSetAdapter *REST1ResponseDataSetAdapter = new TRESTResponseDataSetAdapter(this);
ClientDataSet1->AfterOpen = &ClientDataSet1AfterOpen;
REST1Client->BaseURL = "my.URL.php";
REST1Request->Client = REST1Client;
REST1Request->Response = REST1Response;
REST1Response->ContentType = "application/json";
REST1ResponseDataSetAdapter->Dataset = ClientDataSet1;
REST1ResponseDataSetAdapter->Response = REST1Response;
REST1ResponseDataSetAdapter->Active = true;
REST1Request->Execute();
TDataSource *DataSource1 = new TDataSource(this);
DataSource1->DataSet = ClientDataSet1;
IWDBGrid1->DataSource = DataSource1;
// dynamic_cast<TIWDBGridColumn*>(IWDBGrid1->Columns->Items[0])->Width = (IWDBGrid1->Width/20) * 02; // => Argument out of range
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ClientDataSet1AfterOpen(TDataSet *DataSet)
{//
dynamic_cast<TIWDBGridColumn*>(IWDBGrid1->Columns->Items[0])->Width = (IWDBGrid1->Width/10) * 2; // => Argument out of range
dynamic_cast<TIWDBGridColumn*>(IWDBGrid1->Columns->Items[1])->Width = (IWDBGrid1->Width/10) * 1;
dynamic_cast<TIWDBGridColumn*>(IWDBGrid1->Columns->Items[2])->Width = (IWDBGrid1->Width/10) * 4;
dynamic_cast<TIWDBGridColumn*>(IWDBGrid1->Columns->Items[3])->Width = (IWDBGrid1->Width/10) * 3;
dynamic_cast<TIWDBGridColumn*>(IWDBGrid1->Columns->Items[0])->Title->Text = "AFirstTitle";
dynamic_cast<TIWDBGridColumn*>(IWDBGrid1->Columns->Items[1])->Title->Text = "ASecondTitle";
dynamic_cast<TIWDBGridColumn*>(IWDBGrid1->Columns->Items[2])->Title->Text = "AThirdTitle";
dynamic_cast<TIWDBGridColumn*>(IWDBGrid1->Columns->Items[3])->Title->Text = "AFourthTitle";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::IWDBGrid1Render(TObject *Sender)
{//
// dynamic_cast<TIWDBGridColumn*>(IWDBGrid1->Columns->Items[0])->Width = (IWDBGrid1->Width/10) * 2; // => Argument out of range
}
//---------------------------------------------------------------------------
I am having the error message "Argument out of range" beginning from the first line and for each line.
Any idea of how to get rid of this error?