0
私はListBoxを持っており、次のように定義されたDrawItemイベントを持っています。 ListBoxの以下のプロパティは、DrawMode = OwnerDrawFixedおよびFormattingEnabled = tureとして設定されます。DrawItemイベントの実行時にListBoxがちらつくのはなぜですか?
私は、プログラムを実行し、複数の項目やオブジェクトをListBoxに追加すると、実際にはちらつきがあります。私は正確に何が問題なのかよく分かりません。私は他のwinformsで非常に似たセットアップでListBoxを持っていて、それらはちらつくことはありません。私はちらつきListBoxでwinformのイメージをキャプチャしようとしましたが、キャプチャされたイメージは毎回ListBoxを点滅させませんでした。
method HTrendFrm.AGroupList_DrawItem(sender: System.Object; e: System.Windows.Forms.DrawItemEventArgs);
var
lb:ListBox;
tg:TTrendGroup;
begin
if e.Index = -1 then exit;
lb := (sender as ListBox);
tg := TTrendGroup(LoggingGroup.Item[e.Index]);
if tg.Enabled then
begin
if ((e.State and DrawItemState.Selected) = DrawItemState.Selected) then
begin
lb.ForeColor:=Color.White;
e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
end
else
lb.ForeColor := Color.Black;
end
else
lb.ForeColor := Color.LightGray;
lb.CreateGraphics.DrawString(tg.name,new Font('Arial',9,FontStyle.Bold),new SolidBrush(lb.ForeColor),e.Bounds.Left+5,e.Bounds.Top);
if ((e.State and DrawItemState.Focus) <> DrawItemState.Checked) then
e.DrawFocusRectangle();
end;
ListBoxのちらつきの原因は何ですか?事前に
おかげで、
ダブルバッファーのスタイルを設定する必要があります。http://msdn.microsoft.com/en-us/library/b367a457.aspx – asawyer
私はDelphiについてよくわかりませんが、私はあなたが 'e.Graphics 'lb.CreateGraphics'の代わりに' – LarsTech