Click here to Skip to main content
15,915,611 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionMenu bars based on users............. Pin
Member 38798817-Mar-07 22:11
Member 38798817-Mar-07 22:11 
AnswerRe: Menu bars based on users............. Pin
haggenx8-Mar-07 8:25
haggenx8-Mar-07 8:25 
GeneralRe: Menu bars based on users............. Pin
Member 38798818-Mar-07 17:13
Member 38798818-Mar-07 17:13 
AnswerRe: Menu bars based on users............. Pin
Jelle Stokroos8-Mar-07 10:15
Jelle Stokroos8-Mar-07 10:15 
GeneralRe: Menu bars based on users............. Pin
Member 38798818-Mar-07 17:07
Member 38798818-Mar-07 17:07 
AnswerRe: Menu bars based on users............. Pin
Jelle Stokroos9-Mar-07 5:59
Jelle Stokroos9-Mar-07 5:59 
GeneralRe: Menu bars based on users............. Pin
haggenx9-Mar-07 7:31
haggenx9-Mar-07 7:31 
QuestionDatabinding Issue Pin
Neily There7-Mar-07 22:09
Neily There7-Mar-07 22:09 
Create a project, add a simple class that implements System.ComponentModel.INotifyPropertyChanged, add a couple of string properties to the class. Now add a binding source to the form, and bind it to an instance of the class.
Now add text boxes and bind them to the properties of the class, also add a button.
In the Form Load event create an instance of your class and set the binding datasource to the instance of the class
In a button click event handler return the values of the databound properties by using:
ctype(Me.BindingContext(BindingSource1, "myPropertyname1").Current, String)
build and execute
DO NOT CHANGE THE VALUES IN THE TEXTBOXES
What does the code (from above)return...
For me it returns only the 1st Char of each of the bound properties!
Now alter the contents of the text box(es) and hey presto it will now return the whole string value.

Is it me?
Am i doing something wrong?
Help!


Below is some sample code for what i mean:
THE CLASS:

Public Class Fruit
Implements System.ComponentModel.INotifyPropertyChanged

Public Event PropertyChanged As System.ComponentModel.PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

Private Sub NotifyPropertyChanged(ByVal info As String)
RaiseEvent PropertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(info))
End Sub

Private idValue As Guid = Guid.NewGuid()
Private strPlums As String
Private strApples As String
Private strPears As String

Private Sub New()
Plums = "None"
Apples = "None"
Pears = "None"
End Sub

Public Shared Function CreateNewFruit() As Fruit
Return New Fruit
End Function

Public ReadOnly Property ID() As Guid ' Psuedo key Value
Get
Return Me.idValue
End Get
End Property

Public Property Plums() As String
Get
Return Me.strPlums
End Get
Set(ByVal value As String)
Me.strPlums = value
NotifyPropertyChanged("Plums")
End Set
End Property
Public Property Apples() As String
Get
Return Me.strApples
End Get
Set(ByVal value As String)
Me.strApples = value
NotifyPropertyChanged("Apples")
End Set
End Property
Public Property Pears() As String
Get
Return Me.strPears
End Get
Set(ByVal value As String)
Me.strPears = value
NotifyPropertyChanged("Pears")
End Set
End Property

End Class

THE FORM:

Public Class Form1

Public WithEvents Fruits As Fruit

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Fruits = Fruit.CreateNewFruit
With Fruits
.Apples = "Bramley"
.Pears = "Conference"
.Plums = "Victoria"
End With

BindingSource1.DataSource = Fruits

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strNowPlums As String
Dim strNowApples As String
Dim strNowPears As String


strNowPlums = CType(Me.BindingContext(BindingSource1, "Plums").Current, String)
strNowApples = CType(Me.BindingContext(BindingSource1, "Apples").Current, String)
strNowPears = CType(Me.BindingContext(BindingSource1, "Pears").Current, String)

Label1.Text = strNowPlums
Label2.Text = strNowApples
Label3.Text = strNowPears

' The labels will show 'V', 'B', and 'C' but if you manually change the textboxes and click again it works properly!!

End Sub
End Class
QuestionColin Angus Mackay thanks for the cite Pin
Adekolurejo7-Mar-07 22:01
Adekolurejo7-Mar-07 22:01 
AnswerRe: Colin Angus Mackay thanks for the cite Pin
Colin Angus Mackay7-Mar-07 22:13
Colin Angus Mackay7-Mar-07 22:13 
Questionhow to attach falsh in vb.net??? Pin
bhawna_k7-Mar-07 20:43
bhawna_k7-Mar-07 20:43 
QuestionBindingcontext child_to_parent Pin
epkjoha7-Mar-07 20:35
epkjoha7-Mar-07 20:35 
QuestionHow do I change the background color of a command button Pin
ArchaBhandare7-Mar-07 19:43
ArchaBhandare7-Mar-07 19:43 
QuestionConnection String to the database. Pin
thesemplice7-Mar-07 19:05
thesemplice7-Mar-07 19:05 
AnswerRe: Connection String to the database. Pin
thesemplice7-Mar-07 19:06
thesemplice7-Mar-07 19:06 
AnswerRe: Connection String to the database. Pin
Colin Angus Mackay7-Mar-07 22:12
Colin Angus Mackay7-Mar-07 22:12 
AnswerRe: Connection String to the database. Pin
Dave Kreskowiak8-Mar-07 2:56
mveDave Kreskowiak8-Mar-07 2:56 
GeneralRe: Connection String to the database. Pin
thesemplice8-Mar-07 18:25
thesemplice8-Mar-07 18:25 
Questionretrieving time and date from system. Pin
manni_n7-Mar-07 19:02
manni_n7-Mar-07 19:02 
AnswerRe: retrieving time and date from system. Pin
The ANZAC7-Mar-07 22:46
The ANZAC7-Mar-07 22:46 
GeneralRe: retrieving time and date from system. Pin
manni_n8-Mar-07 2:17
manni_n8-Mar-07 2:17 
Questionshrinking and expanding Pin
balakpn7-Mar-07 17:48
balakpn7-Mar-07 17:48 
AnswerRe: shrinking and expanding Pin
TwoFaced7-Mar-07 17:52
TwoFaced7-Mar-07 17:52 
QuestionControl's Visible Property Pin
sdkgolf7-Mar-07 17:15
sdkgolf7-Mar-07 17:15 
AnswerRe: Control's Visible Property Pin
TwoFaced7-Mar-07 17:50
TwoFaced7-Mar-07 17:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.