Hi,
I want to use databinding on a property for a class that I have created, but
I can't make it work. Below is a contrived example to illustrate the
problem.
It seems that I can't databind properties that I have created, is there a
way to do this?
Thanks,
Martin.
Public Class Form1
Public Class Class1
Inherits Button
Public MyValue As String = "Default Value"
End Class
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim t As New Class1
' This line would work as expected
' ----------------------------------
' TextBox1.DataBindings.Add("Text", t, "Size")
' This line causes runtime error:
' Cannot bind to property or column MyValue on DataSource.
' Parameter name: dataMember
' -------------------------------------------------------------
TextBox1.DataBindings.Add("Text", t, "MyValue")
End Sub
End Class 2 1982
Martin,
You might try making MyValue a public property instead of a public field.
Kerry Moorman
"Martin Horn" wrote: Hi,
I want to use databinding on a property for a class that I have created, but I can't make it work. Below is a contrived example to illustrate the problem.
It seems that I can't databind properties that I have created, is there a way to do this?
Thanks,
Martin.
Public Class Form1
Public Class Class1 Inherits Button Public MyValue As String = "Default Value" End Class
Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Dim t As New Class1
' This line would work as expected ' ---------------------------------- ' TextBox1.DataBindings.Add("Text", t, "Size")
' This line causes runtime error: ' Cannot bind to property or column MyValue on DataSource. ' Parameter name: dataMember ' ------------------------------------------------------------- TextBox1.DataBindings.Add("Text", t, "MyValue") End Sub
End Class
Thanks Kerry, that did it.
To be honest I thought I had already tried that, must have got confused
somewhere along the line.
Martin.
"Kerry Moorman" <Ke**********@discussions.microsoft.com> wrote in message
news:33**********************************@microsof t.com... Martin,
You might try making MyValue a public property instead of a public field.
Kerry Moorman
"Martin Horn" wrote:
Hi,
I want to use databinding on a property for a class that I have created, but I can't make it work. Below is a contrived example to illustrate the problem.
It seems that I can't databind properties that I have created, is there a way to do this?
Thanks,
Martin.
Public Class Form1
Public Class Class1 Inherits Button Public MyValue As String = "Default Value" End Class
Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Dim t As New Class1
' This line would work as expected ' ---------------------------------- ' TextBox1.DataBindings.Add("Text", t, "Size")
' This line causes runtime error: ' Cannot bind to property or column MyValue on DataSource. ' Parameter name: dataMember ' ------------------------------------------------------------- TextBox1.DataBindings.Add("Text", t, "MyValue") End Sub
End Class This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Alex Bibiano |
last post by:
I have a typed dataset in my WinForm and a textbox with databinding to the
dataset (all without code). Now, in a button event, I assign a new dataset
(retrieved from a function) to the dataset a...
|
by: Johann Blake |
last post by:
I have a form with textboxes that are bound to a dataset. The dataset
contains two tables and some of the textboxes use data from one table
while other textboxes use data from the other table. I...
|
by: HAN(removethis)twister |
last post by:
I've tried to create 11 textboxes as variables (not actually visible in
the program, not in Windows Form Designer) and have set DataBindings to
the text properties of the TextBoxes BUT according to...
|
by: Graham Blandford |
last post by:
Hi all,
I haven't received any replies to a previous question I posted regarding
problems I was having with databound textboxes.. so I'll try a different
angle...
Can anyone point me in the...
|
by: C Glenn |
last post by:
This is admitedly vague. But so is my understanding of the problem.
I'm using this chunk of code:
retControl.DataBindings.Add(ctrlBinding.PropertyName,DataSource,BindingField);
This resolves...
|
by: XenReborn |
last post by:
Ok this should be simple.
I made a form, added a combobox (for selecting items to edit, not for updating fields), several textboxes, a few checkboxes etc. On formshow it connects to my database,...
|
by: marcf |
last post by:
Hi everyone,
I've just studio using VS2008 and have a quick question regarding databindings, i'm fairly handy with vb6 so this question really relates to good practice rather than actual coding.
...
|
by: =?Utf-8?B?Tmljb2xhcw==?= |
last post by:
Yes another question about databindings.
All my controls are have databindings and works fine for navigating, adding,
deleting etc.
What I want is when I create a New record have those fields...
|
by: janj |
last post by:
Hi all,
I'm having a problem binding two object properties to properties of another object. The code below works as expected when only one binding is added but doesn't work at all (still compiles)...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |