bindingSource.Position = ... doesn't change the current property.

M

Mr. X.

Hello.
I have
bs as BindingSource

When I do :
bs.Position = 3.

Current isn't changed to the position I gave.

What should I do instead ?

Thanks :)
 
A

Armin Zingler

Am 29.05.2010 20:10, schrieb Mr. X.:
Hello.
I have
bs as BindingSource

When I do :
bs.Position = 3.

Current isn't changed to the position I gave.

What should I do instead ?

How do you see that it doesn't change? I've tried it based on the example here:
http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.current(VS.90).aspx

If you add

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
MyBase.OnLoad(e)

PopulateBindingSourceWithFonts()
Debug.WriteLine(bindingSource1.Current.ToString)
bindingSource1.Position = 1
Debug.WriteLine(bindingSource1.Current.ToString)

End Sub

the output is:

[Font: Name=Arial Black, Size=8, Units=3, GdiCharSet=1, GdiVerticalFont=False]
[Font: Name=Bart, Size=9, Units=3, GdiCharSet=1, GdiVerticalFont=False]

So, Current does change in this case.
 
M

Mr. X.

O.K.
My mistake.
I didn't free an object that is connected to binding-source.
By doing that, some strange things happen.

Thanks :)

Armin Zingler said:
Am 29.05.2010 20:10, schrieb Mr. X.:
Hello.
I have
bs as BindingSource

When I do :
bs.Position = 3.

Current isn't changed to the position I gave.

What should I do instead ?

How do you see that it doesn't change? I've tried it based on the example
here:
http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.current(VS.90).aspx

If you add

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
MyBase.OnLoad(e)

PopulateBindingSourceWithFonts()
Debug.WriteLine(bindingSource1.Current.ToString)
bindingSource1.Position = 1
Debug.WriteLine(bindingSource1.Current.ToString)

End Sub

the output is:

[Font: Name=Arial Black, Size=8, Units=3, GdiCharSet=1,
GdiVerticalFont=False]
[Font: Name=Bart, Size=9, Units=3, GdiCharSet=1, GdiVerticalFont=False]

So, Current does change in this case.
 

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