Community discussion forum

how to change backcolor at runtime

Tags: db India
  • 1 year ago

    hello sir

    i have one Window form(vb.net) name sample

    i have database including backcolor and forecolor field

    like red,blue...

    i want that when i apply changes in database

    form (sample) color should be changed when it load

     by comparing from database backcolor field

    i have following code

    ktcn = New SqlConnection("server=localhost;Integrated Security=true;database=KT_IMS")

    ktcn.Open()

    ktcmd =
    New SqlCommand("select backcolor from appearance", ktcn)

    ktdra = ktcmd.ExecuteReader

    While (ktdra.Read)

    'Dim ifa As Color

    Dim ifa1 As String

    ifa1 = ktdra.GetString(0)

    ' ifa = Khaki

    '

    Label1.BackColor = ifa

    Error occured::value of type string cannot be converted into system.drawing.color

    ' Label1.BackColor.ktdra.GetString(0)

     

    End While

     

  • 1 year ago

    [quote user="shahid123"]Label1.BackColor = ifa[/quote]

    I would try changing the above to:

    Label1.BackColor = System.Drawing.Color.FromName("Red")

     

  • 1 year ago

    thanks

Post a reply

Enter your message below

Sign in or Join us (it's free).

We'd love to hear what you think! Submit ideas or give us feedback