Set dynamic Panel Scrollbar style using C# and VB.Net in ASP.Net

Last Reply 27 days ago By pandeyism

Posted 27 days ago

how to add style on panel Scrollbar like width, track color, arrow color in scroll.

           Panel Pnlcomment = new Panel();
           Pnlcomment.ID = "Pnlcomment";
           Pnlcomment.Style.Add("overflow", "scroll");
           Pnlcomment.Style.Add("overflow-x", "hidden");
           Pnlcomment.Style.Add("border-radius", "12px");
           Pnlcomment.Style.Add(" border", "3px solid #fff");
           Pnlcomment.Style.Add("max-height", "200px");
           Pnlcomment.Style.Add("width", "150px");
           Pnlcomment.Style.Add("background-color", "white");
           DataTable dt = new DataTable();
           dt = new DataTable();
           dt.Columns.AddRange(new DataColumn[2] { new DataColumn("Name"), new DataColumn("Status") });
           dt.Rows.Add("John", "Pending");
           dt.Rows.Add("Rick", "Complete");
           dt.Rows.Add("Andrew", "Complete");
           dt.Rows.Add("Peter", "Pending");
           dt.Rows.Add("Mudassar", "Complete");
           dt.Rows.Add("John", "Pending");
           dt.Rows.Add("Rick", "Complete");
           dt.Rows.Add("Andrew", "Complete");
           dt.Rows.Add("Peter", "Pending");
           dt.Rows.Add("Mudassar", "Complete");
           dt.Rows.Add("John", "Pending");
           dt.Rows.Add("Rick", "Complete");
           dt.Rows.Add("Andrew", "Complete");
           dt.Rows.Add("Peter", "Pending");
           dt.Rows.Add("Mudassar", "Complete");
           this.gvCustomers.DataSource = dt;
           this.gvCustomers.DataBind();
           Pnlcomment.Controls.Add(gvCustomers);
           form1.Controls.Add(Pnlcomment);

 

You are viewing reply posted by: pandeyism 27 days ago.
Posted 27 days ago

Hi IamAzhar,

Refer below sample.

HTML

<asp:GridView ID="gvCustomers" runat="server" AutoGenerateColumns="false">
    <Columns>
        <asp:BoundField DataField="Name" HeaderText="Name" />
        <asp:BoundField DataField="Status" HeaderText="Status" />
    </Columns>
</asp:GridView>

Namespaces

C#

using System.Data;

VB.Net

Imports System.Data

Code

C#

protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
    {
        Panel Pnlcomment = new Panel();
        Pnlcomment.ID = "Pnlcomment";
        Pnlcomment.Style.Add("overflow", "scroll");
        Pnlcomment.Style.Add("overflow-x", "hidden");
        Pnlcomment.Style.Add("border-radius", "12px");
        Pnlcomment.Style.Add(" border", "3px solid #fff");
        Pnlcomment.Style.Add("max-height", "200px");
        Pnlcomment.Style.Add("width", "250px");
        Pnlcomment.Style.Add("background-color", "white");
        Pnlcomment.Style.Add("color", "green");
        Pnlcomment.Style.Add("scrollbar-arrow-color", "#2FC5C0");
        Pnlcomment.Style.Add("scrollbar-darkshadow-color", "blue");
        Pnlcomment.Style.Add("scrollbar-shadow-color", "blue");
        Pnlcomment.Style.Add("scrollbar-track-color", "#E7F2FA");
        DataTable dt = new DataTable();
        dt = new DataTable();
        dt.Columns.AddRange(new DataColumn[2] { new DataColumn("Name"), new DataColumn("Status") });
        dt.Rows.Add("John", "Pending");
        dt.Rows.Add("Rick", "Complete");
        dt.Rows.Add("Andrew", "Complete");
        dt.Rows.Add("Peter", "Pending");
        dt.Rows.Add("Mudassar", "Complete");
        dt.Rows.Add("John", "Pending");
        dt.Rows.Add("Rick", "Complete");
        dt.Rows.Add("Andrew", "Complete");
        dt.Rows.Add("Peter", "Pending");
        dt.Rows.Add("Mudassar", "Complete");
        dt.Rows.Add("John", "Pending");
        dt.Rows.Add("Rick", "Complete");
        dt.Rows.Add("Andrew", "Complete");
        dt.Rows.Add("Peter", "Pending");
        dt.Rows.Add("Mudassar", "Complete");
        this.gvCustomers.DataSource = dt;
        this.gvCustomers.DataBind();
        Pnlcomment.Controls.Add(gvCustomers);
        form1.Controls.Add(Pnlcomment);
    }
}

VB.Net

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)Handle Me.Load
    If Not Me.IsPostBack Then
        Dim Pnlcomment As Panel = New Panel()
        Pnlcomment.ID = "Pnlcomment"
        Pnlcomment.Style.Add("overflow", "scroll")
        Pnlcomment.Style.Add("overflow-x", "hidden")
        Pnlcomment.Style.Add("border-radius", "12px")
        Pnlcomment.Style.Add(" border", "3px solid #fff")
        Pnlcomment.Style.Add("max-height", "200px")
        Pnlcomment.Style.Add("width", "250px")
        Pnlcomment.Style.Add("background-color", "white")
        Pnlcomment.Style.Add("color", "green")
        Pnlcomment.Style.Add("scrollbar-arrow-color", "#2FC5C0")
        Pnlcomment.Style.Add("scrollbar-darkshadow-color", "blue")
        Pnlcomment.Style.Add("scrollbar-shadow-color", "blue")
        Pnlcomment.Style.Add("scrollbar-track-color", "#E7F2FA")
        Dim dt As DataTable = New DataTable()
        dt = New DataTable()
        dt.Columns.AddRange(New DataColumn(1) {New DataColumn("Name"), New DataColumn("Status")})
        dt.Rows.Add("John", "Pending")
        dt.Rows.Add("Rick", "Complete")
        dt.Rows.Add("Andrew", "Complete")
        dt.Rows.Add("Peter", "Pending")
        dt.Rows.Add("Mudassar", "Complete")
        dt.Rows.Add("John", "Pending")
        dt.Rows.Add("Rick", "Complete")
        dt.Rows.Add("Andrew", "Complete")
        dt.Rows.Add("Peter", "Pending")
        dt.Rows.Add("Mudassar", "Complete")
        dt.Rows.Add("John", "Pending")
        dt.Rows.Add("Rick", "Complete")
        dt.Rows.Add("Andrew", "Complete")
        dt.Rows.Add("Peter", "Pending")
        dt.Rows.Add("Mudassar", "Complete")
        Me.gvCustomers.DataSource = dt
        Me.gvCustomers.DataBind()
        Pnlcomment.Controls.Add(gvCustomers)
        form1.Controls.Add(Pnlcomment)
    End If
End Sub

Screenshot