VisualStyles picker in c#

Oct 22 2009 10:35 PM


Hello. I am trying to make some kind of visualStules picker.. here is piece of my code so You can understand what am I doing..

on form load event..
foreach (object stil in Enum.GetValues(typeof(System.Windows.Forms.VisualStyles.VisualStyleState)))
            {
                comboBox1.Items.Add(stil);
            }
than on comboBox1_indexChanged evenent..
Application.VisualStyleState = (System.Windows.Forms.VisualStyles.VisualStyleState)comboBox1.SelectedItem;

that works fine.. but now i want user to see example of the results not to change tne VisualStyle state..
and the example to be drawn in picture box or something.. some form with selected styleState to be drawn and in ComboBox_IndexChange that image, or graphics change.. and finaly if the user like that choise and want to set that style in the application, confirm with dialog.. on button click.. but that is not problem.. the problem is the drawing example..
I want the Example to be something like in the (appairance tab) of Display Properties in WinXp
I was trying something like:
Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            Form2 frm = new Form2();
           
            frm.DrawToBitmap(bmp, new Rectangle(new Point(0,0), frm.Size));
            frm.button1.DrawToBitmap(bmp, new Rectangle(frm.button1.Location, frm.button1.Size));
            frm.textBox1.DrawToBitmap(bmp, new Rectangle(frm.textBox1.Location, frm.textBox1.Size));
            frm.label1.DrawToBitmap(bmp, new Rectangle(frm.label1.Location, frm.label1.Size));
            frm.comboBox1.DrawToBitmap(bmp, new Rectangle(frm.comboBox1.Location, frm.comboBox1.Size));
            frm.checkBox1.DrawToBitmap(bmp, new Rectangle(frm.checkBox1.Location, frm.checkBox1.Size));
            frm.radioButton1.DrawToBitmap(bmp, new Rectangle(frm.radioButton1.Location, frm.radioButton1.Size));
           
            pictureBox1.Image = bmp;
but i don't like the results at all..
thank You, and I hope that somebody will help me solve this..  (Ideas or some code are welcome.. )

Answers (6)