Event on record change

H

Hemang Shah

I have some controls on my form which are bound to a dataset and some which
are not bound.

But whatever record is displayed on the form, I want to populate those
control (datetime, combo, etc.) with the data in the current record.

What event can I do this in ?

PositionChanged of bindingContext - is this called before the record is
current or after ?

if it is after, I can use this.

Please advise.

HS
 
C

Cor Ligthert

Hemang,

For the dateTime and Combo is probably the problem that you have to bind
those to the value.

Probably is that easier than doing it by hand.

I hope this helps?

Cor
 
N

news.microsoft.com

Thanks Cor

But the reason I cannot bind to the dataset is because of the control's
limitation to handle DBNull values and also that multiple comboboxes with
the same datasource act in sync with one another which is unexpected.

:)
 
C

Cor Ligthert

News,

Your first question when it is for the datetimepicker (not tested with a
datetimepicker however I don't know why it would not

\\\
Private Sub myroutine()
Mybinding = New Binding("Value", ds.Tables(0), "mydatfield")
textdatfield.DataBindings.Add(Mybinding)
AddHandler mybinding.Format, AddressOf DBdateTextbox
AddHandler mybinding.Parse, AddressOf TextBoxDBdate
End sub
Private Sub DBdateTextbox(ByVal sender As Object, _
ByVal cevent As ConvertEventArgs)
If cevent.Value Is DBNull.Value Then
cevent.Value = ""
Else
Dim datum As Date
datum = CDate(cevent.Value)
cevent.Value = datum.ToString("d")
End If
End Sub
Private Sub TextBoxDBdate(ByVal sender As Object, _
ByVal cevent As ConvertEventArgs)
If cevent.Value.ToString = "" Then
cevent.Value = DBNull.Value
End If
End Sub
///

For the secondone you have to create for every control a different dataview
When you don't know how tell than what is your datasource at the moment.

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top