SQL Serverテーブルのデータを表示するTcxGridコンポーネントがあります。 CXGrid整数列に画像を表示するにはどうすればよいですか? この列のセルは、0または1にしかなりません。CXGrid整数列に画像を表示するにはどうすればよいですか?
整数の列セルの値が0の場合、 cximagelist.pictureインデックス= 0他 cximagelist.picture指数= 1
SQL Serverテーブルのデータを表示するTcxGridコンポーネントがあります。 CXGrid整数列に画像を表示するにはどうすればよいですか? この列のセルは、0または1にしかなりません。CXGrid整数列に画像を表示するにはどうすればよいですか?
整数の列セルの値が0の場合、 cximagelist.pictureインデックス= 0他 cximagelist.picture指数= 1
あなたはImageComboBox列試みることができる:あなたはおそらく、フォームデザイナで視覚的に上記のほとんどを行うことができます
procedure Test(ACol: TcxGridColumn);
var
props: TcxImageComboBoxProperties;
i: Integer;
item: TcxImageComboBoxItem;
begin
ACol.PropertiesClass := TcxImageComboBoxProperties;
Assert(ACol.Properties is TcxImageComboBoxProperties);
props := TcxImageComboBoxProperties(ACol.Properties);
props.Images := YourImages;
for i in PossibleIndices do
begin
item := props.Items.Add;
item.Description := ''; // or IntToStr(i)
item.Value := i;
if i = 0 then
item.ImageIndex := 0
else
item.ImageIndex := 1;
end;
end;
を。
:
を表示するには、グリッドに列を追加します。イメージを設定し、Properties
の値をImage
に設定します。
実行時に、2つのビットマップ、BM1
とBM2
に表示するビットマップを指定します。
次のように、新しい列のOnCustomDrawCell
にコードを追加します。
コード:もちろん
procedure TForm1.cxGrid1DBTableView1Column1CustomDrawCell(Sender:
TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo:
TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
BM : TBitMap;
ARect : TRect;
I : Integer;
begin
ARect := AViewInfo.Bounds;
// In the next line, 2 is the index of my integer column which
// contains the value which deterimnes the image to display.
I := AViewInfo.GridRecord.Values[2];
if I = 0 then
BM := BM1
else
BM := BM2;
ACanvas.Draw(ARect.Left, ARect.Top, BM);
ADone := True;
end;
、あなたはグリッドに整数フィールドの値を表示したくない場合、あなたは、単にその列を削除したり、False
にそのVisible
プロパティを設定することができます。
ImageComboBoxカラムを試して、すべてのアイテムの説明を ''''に設定することができます。 –