Click here to Skip to main content
15,884,425 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi frnds....

how to add the background color to the cells of the tabel layout panel..

actually i want to add different colors to different cells...

is there any property for that.. plz give me suggestion...

thanks in advance..
Posted
Updated 15-May-11 18:47pm
v2

1 solution

You can create a class derived from System.Windows.Forms.TableLayoutPanel and override System.Windows.Forms.TableLayoutPanel.OnCellPaint to create any custom appearance for the cell.
See a code sample here:
http://msdn.microsoft.com/en-us/library/system.windows.forms.tablelayoutpanel.aspx[^].

Alternatively, you can make arrange child controls of the type System.Windows.Forms.Panel so each cell contains an instance of Panel. The steps (for other child controls like buttons) are described here: http://msdn.microsoft.com/en-us/library/w4yc3e8c(v=VS.90).aspx[^]. After you do it, arrange other controls as children of those panels (use System.Windows.Forms.DockStyle.Fill with Padding). The panels used as pads for other controls can use different background colors.

—SA
 
Share this answer
 
v2
Comments
Harish Reddy K 16-May-11 2:15am    
thankq boss..
nice answer...
Sergey Alexandrovich Kryukov 16-May-11 2:21am    
You're welcome (only please don't call me boss).
Thanks for accepting this answer.
Good luck, call again.
--SA
Harish Reddy K 16-May-11 2:24am    
its ok...
Prasanta_Prince 16-May-11 3:28am    
Good one.
Sergey Alexandrovich Kryukov 16-May-11 4:13am    
Thank you, Prasanta.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900