BindingSource positioning

E

Earl

I've probably asked the wrong question down below, as the issue is with the
datasource rather than the datagridview. What I'd like to do is position the
binding source to where no row is selected. Even setting
BindingSource.Position = -1 does not leave me with no rows selected. What
I'm doing is having the user click a "New" button to clear textboxes that
are bound to the same bindingsource as the grid. So I naturally want those
boxes to clear so the user can enter a new row of data, then I'll apply the
update, etc. While I've not used databinding much, it sure seems like I
should be able to clear the selected bindingsource row or position. Any
advice?
 
E

Earl

No, but that may be because I expect too much :=) I would expect AddNew to
position the row to the newly added row and also clear the textboxes (since
the newly added row is now blank).
 
E

Earl

Not sure if how I handled this is "good practice" or not, but what I ended
up doing was using the MoveLast method and then clearing the textboxes
within a custom method:

datagridview.AddNew();
bindingSource.MoveLast();
ClearInputPanel();

It would still seem to me that if you landed on an empty row in the
datagridview (bound to the bindingsource) then the textboxes that are also
bound to the bindingsource would clear to the contents of the columns in the
*empty* bound rows. Wish I understood why not, but I reckon this is why I
have always dodged data-binding.
 

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