Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. DataBindings do not appear to function properly

DataBindings do not appear to function properly

Scheduled Pinned Locked Moved Visual Basic
csharpquestionannouncement
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TJO1
    wrote on last edited by
    #1

    Dear Collegues, I thought I might try to use databindings to create a dialog that will enable a user to change some default colours. I can get the panel to show the colour stored in my class but I can't seem to get the class colour to update when the colour of the panel is changed. I have a databinding between the BackColor of a Panel control and the LineColour property of a ProjectPreferences Class. The details of each follow. When I show the dlgPrefs dialog, the pnlLineColour.BackColor is correct. After I change the pnlLineColour.BackColor using the ColorDialog, the m_pp.LineColour does not change to suit. Have I done this correctly or am I expecting too much? I am using VB.NET 2003 I have a class ProjectPrefences which holds the data. e.g. ProjectPreferences.LineColour:- Public Property LineColour() As Color Get Return m_LineColour End Get Set(ByVal Value As Color) m_LineColour = Value End Set End Property I call the dialog with the following code:- Dim MyPrefs As New ProjectPreferences Private Sub mnuPreferences_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuPreferences.Click Dim dlg As New dlgPrefs dlg.PreferenceData = MyPrefs If dlg.ShowDialog() = DialogResult.OK Then MyPrefs = dlg.PreferenceData End If End Sub The Dialog code is:- Public Class dlgPrefs Inherits System.Windows.Forms.Form Private m_pp As ProjectPreferences Public Property PreferenceData() As ProjectPreferences Get Return m_pp End Get Set(ByVal Value As ProjectPreferences) unBindData() m_pp = Value If Not m_pp Is Nothing Then BindData() End If End Set End Property ''' this routine handles a click in all of the colour panels Private Sub ColourPanel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pnlLineColour.Click, pnlElementColour.Click Dim cdlg As New ColorDialog cdlg.Color = sender.backcolor If cdlg.ShowDialog = DialogResult.OK Then sender.BackColor = cdlg.Color 'changes the panel.BackColor End If End Sub Private Sub BindData() 'pnlElementColour is a Panel on the dialog Me.pnlElementColour.DataBindings.Add("BackColor", m_pp, "ElementColour") Me.pnlLineColou

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups