มาเปลี่ยน Skin ของ cxgrid กันเถอะ

--

เคยเจอไหมครับ เวลาออกแบบแล้ว skin ไม่โดนใจ User ให้เขาเปลี่ยนกันเองเลยละกันครับ

ก่อนอื่นเลยเราต้อง Uses dxSkinsForm,dxSkinsLookAndFeelPainter,dxSkinInfo ก่อนครับ

ขั้นตอนแรกเราก็ต้องดึงชื่อ skin จากระบบมาใส่ใน Combobox เพื่อเลือกก่อน

procedure TForm5.FormCreate(Sender: TObject);
var
ASkinInfo: TdxSkinInfo;
I : Integer;
begin
if RootLookAndFeel.Painter.GetPainterData(ASkinInfo) then
begin
for I := 0 to cxLookAndFeelPaintersManager.Count — 1 do
if cxLookAndFeelPaintersManager.Items[I] is TdxSkinLookAndFeelPainter then
cxComboBox1.Properties.Items.Add(cxLookAndFeelPaintersManager.Items[I].LookAndFeelName);
end;
end;

จากนั้นใน Event Click นั้นก็ใส่ code ดังนี้

cxLookAndFeelController1.NativeStyle := False;
cxLookAndFeelController1.SkinName := cxComboBox1.Text;
cxPageControl1.LookAndFeel.SkinName := cxComboBox1.Text;;
cxComboBox1.Style.LookAndFeel.SkinName := cxComboBox1.Text;
cxbutton1.LookAndFeel.SkinName := cxComboBox1.Text;

ตัวที่เป็น skin ของฟอร์ม นั้นสามารถใช้

cxLookAndFeelController1.SkinName := cxComboBox1.Text;

ได้เลยแต่ตัว Controll ตัวอื่นจะไม่เปลี่ยน ต้องไล่เปลี่ยนเองครับ

สามารถ Download code ตัวอย่างได้ที่ https://github.com/piyanatn/dxSkinChange

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response