Profile Picture

Change TabControl Background to Gradient

Posted By Gary Smith 15 Years Ago
Author
Message
Gary Smith
Posted 15 Years Ago
View Quick Profile
Forum Member

Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 39, Visits: 1
How would one go about changing the background color of the tabbed pages of a TabControl to the Gradient found on the other controls when using the NUIManagerController to define the look and feel of the application?  Buttons, panels etc appear with a Gradient but the pages of the TabControl are solid.



Angel Chorbadzhiev
Posted 15 Years Ago
View Quick Profile
Supreme Being

Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)

Group: Forum Members
Last Active: Last Month
Posts: 139, Visits: 184

Hi Gary,

I can think of 2 solutions:

1. You can drop on NUIPanel on the tab page and set its Dock property to Fill.

2. You can create your tab page class that inherits NTabPage and override OnPaintBackground method to fill itself with a gradient. Then instead of adding the NTabPage into the NTabControl.TabPages collection add instance of this new class.

Here is an implementation of this class:

Imports System.Drawing

Imports System.Drawing.Drawing2D

Imports Nevron.UI.WinForm.Controls

Public Class MyNTabPage

    Inherits NTabPage

    Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)

        Dim g As Graphics = e.Graphics

        Dim r As Rectangle = ClientRectangle

        Dim c1 As Color = Palette.ControlLight

        Dim c2 As Color = Palette.ControlDark

        Using brush As LinearGradientBrush = New LinearGradientBrush(r, c1, c2, 90.0F)

            g.FillRectangle(brush, r)

        End Using

    End Sub

End Class

 

Regards,

Angel.



Gary Smith
Posted 15 Years Ago
View Quick Profile
Forum Member

Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 39, Visits: 1

Thanks for the help Angel. I can get it to work, but then the labels I add dynamically at run time dont have transparent backgrounds so it didnt work quite like I wanted, no fault of you or Nevrons controls...

Thanks

 



Angel Chorbadzhiev
Posted 15 Years Ago
View Quick Profile
Supreme Being

Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)

Group: Forum Members
Last Active: Last Month
Posts: 139, Visits: 184

Gary,

If these labels are standard .NET labels you can setup their back color to be transparent:

label1.BackColor = Color.Transparent



Gary Smith
Posted 15 Years Ago
View Quick Profile
Forum Member

Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)Forum Member (39 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 39, Visits: 1

Yes I tried that, but it didnt seem to make a difference. Then I read where the parent property must be set to the control its placed else it will be transparent to the form background color. so....

I'm adding labels in a loop dynamically at runtime to the NTabControl, so for each page of the NTabControl I do:

Dim nPanel As New NUIPanel
nPanel.Name =
"nPanel" & y.ToString
nPanel.Dock = DockStyle.Fill
nPanel.Parent = myDataPage(y)
myDataPage(y).Controls.Add(nPanel)
nPanel.SendToBack()

then in the inner loop that addes the labels to each page I do:

Dim
qLabel As New Label
myDataPage(y).Controls.Add(qLabel)
qLabel.Parent = nPanel
qLabel.BackColor = Color.Transparent
qLabel.BringToFront()

And this worked....weird...but it works....

Thanks for your help!


 





Similar Topics


Reading This Topic