BackColor









How do I use Back Color
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: frmColor.cs Copy
86   private void InitializeComponent()
87   {
88             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ColorInput));
89             this.Blue = new System.Windows.Forms.TextBox();
90             this.label4 = new System.Windows.Forms.Label();
91             this.Green = new System.Windows.Forms.TextBox();
92             this.label3 = new System.Windows.Forms.Label();
93             this.Red = new System.Windows.Forms.TextBox();
94            this.label2 = new System.Windows.Forms.Label();
95             this.label1 = new System.Windows.Forms.Label();
96             this.Cancel = new System.Windows.Forms.Button();
97             this.OK = new System.Windows.Forms.Button();
98             this.SuspendLayout();
99             //
100             // Blue
101             //
102             this.Blue.Location = new System.Drawing.Point(103, 112);
103             this.Blue.Name = "Blue";
104             this.Blue.Size = new System.Drawing.Size(100, 20);
105             this.Blue.TabIndex = 17;
106             ////
107             // label4
108             //
109             this.label4.ForeColor = System.Drawing.Color.Blue;
110             this.label4.Location = new System.Drawing.Point(32, 112);
111             this.label4.Name = "label4";
112             this.label4.Size = new System.Drawing.Size(32, 16);
113             this.label4.TabIndex = 16;
114             this.label4.Text = "Blue";
115            // //
116            // // Green
117            // //
118             this.Green.Location = new System.Drawing.Point(103, 80);
119             this.Green.Name = "Green";
120             this.Green.Size = new System.Drawing.Size(100, 20);
121             this.Green.TabIndex = 15;
122             //
123            // // label3
124            // //
125             this.label3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
126             this.label3.Location = new System.Drawing.Point(32, 80);
127             this.label3.Name = "label3";
128             this.label3.Size = new System.Drawing.Size(32, 16);
129             this.label3.TabIndex = 14;
130             this.label3.Text = "Green";
131             //
132            // // Red
133            // //
134             this.Red.Location = new System.Drawing.Point(103, 48);
135             this.Red.Name = "Red";
136             this.Red.Size = new System.Drawing.Size(100, 20);
137             this.Red.TabIndex = 13;
138            // //
139            // // label2
140            // //
141             this.label2.ForeColor = System.Drawing.Color.Red;
142             this.label2.Location = new System.Drawing.Point(32, 48);
143             this.label2.Name = "label2";
144             this.label2.Size = new System.Drawing.Size(32, 16);
145             this.label2.TabIndex = 12;
146             this.label2.Text = "Red";
147             //
148            // // label1
149            // //
150             this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
151             this.label1.ForeColor = System.Drawing.Color.Blue;
152             this.label1.Location = new System.Drawing.Point(16, 16);
153             this.label1.Name = "label1";
154             this.label1.Size = new System.Drawing.Size(281, 24);
155             this.label1.TabIndex = 11;
156             this.label1.Text = "Nhập các giá trị màu từ -255 đến 255";
157             // this.label1.Click += new System.EventHandler(this.label1_Click);
158            // //
159            // // Cancel
160            // //
161             this.Cancel.Location = new System.Drawing.Point(176, 178);
162             this.Cancel.Name = "Cancel";
163             this.Cancel.Size = new System.Drawing.Size(75, 23);
164             this.Cancel.TabIndex = 9;
165             this.Cancel.Text = "Bỏ qua";
166             //
167            // // OK
168            // //
169             this.OK.Location = new System.Drawing.Point(19, 178);
170             this.OK.Name = "OK";
171             this.OK.Size = new System.Drawing.Size(75, 23);
172             this.OK.TabIndex = 10;
173             this.OK.Text = "Đồng ý";
174            // this.OK.Click += new System.EventHandler(this.OK_Click);
175             //
176             // ColorInput
177             //
178             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
179             this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
180             this.ClientSize = new System.Drawing.Size(309, 226);
181             this.Controls.Add(this.Blue);
182             this.Controls.Add(this.label4);
183             this.Controls.Add(this.Green);
184             this.Controls.Add(this.label3);
185             this.Controls.Add(this.Red);
186             this.Controls.Add(this.label2);
187             this.Controls.Add(this.label1);
188             this.Controls.Add(this.OK);
189             this.Controls.Add(this.Cancel);
190             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
191             this.Name = "ColorInput";
192             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
193             this.Text = "CHON MAU";
194             //this.Load += new System.EventHandler(this.ColorInput_Load);
195             this.ResumeLayout(false);
196             this.PerformLayout();
197
198   }
File name: frmMain.cs Copy
59   private void InitializeComponent()
60   {
61             this.components = new System.ComponentModel.Container();
62             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));
63             this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
64             this.menuItem1 = new System.Windows.Forms.MenuItem();
65             this.FileLoad = new System.Windows.Forms.MenuItem();
66             this.FileSave = new System.Windows.Forms.MenuItem();
67             this.FileExit = new System.Windows.Forms.MenuItem();
68             this.menuItem4 = new System.Windows.Forms.MenuItem();
69             this.FilterGrayScale = new System.Windows.Forms.MenuItem();
70             this.FilterColor = new System.Windows.Forms.MenuItem();
71             this.menuItem3 = new System.Windows.Forms.MenuItem();
72             this.EmbossLaplacian = new System.Windows.Forms.MenuItem();
73             this.EdgeDetectQuick = new System.Windows.Forms.MenuItem();
74             this.SuspendLayout();
75             //
76             // mainMenu1
77             //
78             this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
79             this.menuItem1,
80             this.menuItem4,
81             this.menuItem3});
82             //
83             // menuItem1
84             //
85             this.menuItem1.Index = 0;
86             this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
87             this.FileLoad,
88             this.FileSave,
89             this.FileExit});
90             this.menuItem1.Text = "File";
91             //this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
92             //
93             // FileLoad
94             //
95             this.FileLoad.Index = 0;
96             this.FileLoad.Shortcut = System.Windows.Forms.Shortcut.CtrlO;
97             this.FileLoad.Text = "Mở file";
98             this.FileLoad.Click += new System.EventHandler(this.File_Load);
99             //
100             // FileSave
101             //
102             this.FileSave.Index = 1;
103             this.FileSave.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
104             this.FileSave.Text = "Lưu file";
105             this.FileSave.Click += new System.EventHandler(this.File_Save);
106             //
107             // FileExit
108             //
109             this.FileExit.Index = 2;
110             this.FileExit.Text = "Thoát";
111             this.FileExit.Click += new System.EventHandler(this.File_Exit);
112             //
113             // menuItem4
114             //
115             this.menuItem4.Index = 1;
116             this.menuItem4.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
117             this.FilterGrayScale,
118             this.FilterColor});
119             this.menuItem4.Text = "Biến đổi màu";
120             //
121             // FilterGrayScale
122             //
123             this.FilterGrayScale.Index = 0;
124             this.FilterGrayScale.Text = "Xám";
125             this.FilterGrayScale.Click += new System.EventHandler(this.Filter_GrayScale);
126             //
127             // FilterColor
128             //
129             this.FilterColor.Index = 1;
130             this.FilterColor.Text = "Màu";
131             this.FilterColor.Click += new System.EventHandler(this.Filter_Color);
132             //
133             // menuItem3
134             //
135             this.menuItem3.Index = 2;
136             this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
137             this.EmbossLaplacian,
138             this.EdgeDetectQuick});
139             this.menuItem3.Text = "Phát hiện biên";
140             //this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
141             //
142             // EmbossLaplacian
143             //
144             this.EmbossLaplacian.Index = 0;
145             this.EmbossLaplacian.Text = "Laplacian_Emboss";
146             this.EmbossLaplacian.Click += new System.EventHandler(this.OnEmbossLaplacian);
147             //
148             // EdgeDetectQuick
149             //
150             this.EdgeDetectQuick.Index = 1;
151             this.EdgeDetectQuick.Text = "EdgeDetectQuick";
152             this.EdgeDetectQuick.Click += new System.EventHandler(this.OnEdgeDetectQuick);
153             //
154             // frmMain
155             //
156             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
157             this.BackColor = System.Drawing.SystemColors.ControlLightLight;
158             this.BackgroundImage = global::CSharpFilters.Properties.Resources.Daewoo;
159             this.ClientSize = new System.Drawing.Size(349, 237);
160             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
161             this.Menu = this.mainMenu1;
162             this.Name = "frmMain";
163             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
164             this.Text = "Xu ly anh";
165             //this.Load += new System.EventHandler(this.Form1_Load);
166             this.ResumeLayout(false);
167
168   }
File name: frmMainMenu.cs Copy
249         public void GetData()
250         {
251             try
252             {
253                 con = new SqlConnection(cs.DBConn);
254                 con.Open();
255                 String sql = "SELECT Product.ProductID,ProductName,Features,Price,sum(Quantity),sum(Price*Quantity) from Temp_Stock,Product where Temp_Stock.ProductID=Product.ProductID group by Product.productID,productname,Price,Features,Quantity having(Quantity>0) order by ProductName";
256                 cmd = new SqlCommand(sql, con);
257                 rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
258                 dataGridView1.Rows.Clear();
259                 while (rdr.Read() == true)
260                 {
261                     dataGridView1.Rows.Add(rdr[0], rdr[1], rdr[2], rdr[3], rdr[4], rdr[5]);
262                 }
263                 foreach (DataGridViewRow r in this.dataGridView1.Rows)
264                 {
265                     if (Convert.ToInt32(r.Cells[4].Value) < 10)
266                     {
267                         r.DefaultCellStyle.BackColor = Color.Red;
268                     }
269                 }
270                 con.Close();
271             }
272             catch (Exception ex)
273             {
274                 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
275             }
276         }
File name: frmMainMenu.cs Copy
309         private void textBox1_TextChanged(object sender, EventArgs e)
310         {
311             try{
312             con = new SqlConnection(cs.DBConn);
313                 con.Open();
314                 String sql = "SELECT Product.ProductID,ProductName,Features,Price,sum(Quantity),sum(Price*Quantity) from Temp_Stock,Product where Temp_Stock.ProductID=Product.ProductID and ProductName like '" + txtProductName.Text + "%' group by product.ProductID,productname,Price,Features,Quantity having(quantity>0) order by ProductName";
315                 cmd = new SqlCommand(sql, con);
316                 rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
317                 dataGridView1.Rows.Clear();
318                 while (rdr.Read() == true)
319                 {
320                     dataGridView1.Rows.Add(rdr[0], rdr[1], rdr[2], rdr[3], rdr[4], rdr[5]);
321                 }
322                 foreach (DataGridViewRow r in this.dataGridView1.Rows)
323                 {
324                 if (Convert.ToInt32(r.Cells[4].Value) < 10)
325                 {
326                     r.DefaultCellStyle.BackColor = Color.Red;
327                 }
328             }
329                 con.Close();
330             }
331             catch (Exception ex)
332             {
333                 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
334             }
335         }
File name: bubble.cs Copy
14         public bubble(string message, msgtype messagetype)
15         {
16             InitializeComponent();
17
18             // Set the text in the bubble from the message in the parameter.
19             lblmessage.Text = message;
20
21             // Change Color based on Message type.
22             if (messagetype.ToString() == "In")
23             {
24                 // incoming User message
25                 this.BackColor = Color.Gray;
26             }
27             else
28             {
29                 // Outgoing Bot Message
30                 this.BackColor = Color.FromArgb(0, 164, 147);
31             }
32             Setheight();
33         }

BackColor 127 lượt xem

Gõ tìm kiếm nhanh...