Quote:
Hello to every One.
So this solved me task. I repleced all standard controls with modified custom controls based on standard controls.
Here is how i did it. If you have better solution please let me know!
1) Create what ever you want with Standard Microsoft Visual Studio Constructor.
2) Create custom controls based on standard controls.
namespace Project_Name
{
public class CustomPanel : Panel
{
private void CustomPanel_Resize(object sender, EventArgs e)
{
if (this.Visible) this.Refresh();
}
public CustomPanel()
{
this.Resize +=new EventHandler(CustomPanel_Resize);
this.SetStyle(ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.OptimizedDoubleBuffer,
true);
}
}
public class CustomTabControl : TabControl
{
private void CustomTabControl_Resize(object sender, EventArgs e)
{
if (this.Visible) this.Refresh();
}
public CustomTabControl()
{
this.Resize +=new EventHandler(CustomTabControl_Resize);
this.SetStyle(ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.OptimizedDoubleBuffer,
true);
}
}
public class CustomButton : Button
{
private void CustomButton_Resize(object sender, EventArgs e)
{
if (this.Visible) this.Refresh();
}
public CustomButton()
{
this.Resize += new EventHandler(CustomButton_Resize);
this.SetStyle(ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.OptimizedDoubleBuffer,
true);
}
}
}
NOTE (1): i created custom controls for all standard controls i used in the project (pictureboxes, checkboxes, menu stripes and so on).
NOTE (2): I need to dynamically create controls. In this case, I always use the this custom controls.
3)In every Form you can find "Form Aame".Designer.cs. Copy this file and rename.
FOR EXALE: You are working with the from named "MainForm".
Then the file name of it`s desinger will have a name "MainForm.Desirgen.cs".
In explorer copy this file and rename it "Custom_MainForm.Designer.cs".
4) Open this new renamed file in your studio. And delete
private System.ComponentModel.IContainer components = null;
and
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
5) Rename this function
private void InitializeComponent()
with some other name i used
private void Initialize_Custom_Component()
6) Using "Ctrl+F -> Repleace " repleace all like this:
For example:
this.panel = new System.Windows.Forms.Panel();
this.button = new System.Windows.Forms.Button();
this.groupBox = new System.Windows.Forms.GroupBox();
this.label = new System.Windows.Forms.Label();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.textBox = new System.Windows.Forms.TextBox();
private System.Windows.Forms.Panel panel ;
private System.Windows.Forms.Button button ;
private System.Windows.Forms.GroupBox groupBox ;
private System.Windows.Forms.Label label ;
private System.Windows.Forms.RadioButton radioButton1 ;
private System.Windows.Forms.TextBox textBox ;
into this
this.panel = new CustomPanel();
this.button = new CustomButton();
this.groupBox = new CustomGroupBox();
this.label = new CustomLabel();
this.radioButton1 = new CustomRadioButton();
this.textBox = new CustomTextBox();
private CustomPanel panel ;
private CustomButton button ;
private CustomGroupBox groupBox ;
private CustomLabel label ;
private CustomRadioButton radioButton1 ;
private CustomTextBoxtextBox ;
7) Go to the constructor of your form and rename
InitializeComponent()
into
Initialize_Custom_Component()
If you all did correct your Controls will never blink again.
But be carefull with resizing your form this may decrease your performance.
So i created a checkbox in my global project properties form and named it - "Use Performance".
If this chekbox is checked iam using standard controls if not i am using my custom controls.
And the final code of the initialization looks like
if (GLOBAL_PROPERTIES.Use_Performance_CheckBox_Checked)
InitializeComponent();
else
Initialize_Custom_Component();
I have 521 controls on my form, and i have 6-7 resizings in second without blinking. I think it is good resault.
I hope this answer will be usefull for somebody.
Happy Coding for all you, my friends.