Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / June 2005

Tip: Looking for answers? Try searching our database.

bindingContext.AddNew not working with binded Combobox in form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jaime - 07 Jun 2005 03:13 GMT
Hi All,

I have a form with a datagrid, several textboxes and one combobox,
representing the detailed of whatever is selected in the datagrid. All the
textboxes and combo are binded like:

textBox.DataBindings.Add( "text", ds, "field1" );

... now I have one combobox that is binded like this
textBox.DataBindings.Add( "SelectedIndex", ds, "field2" );

the combo box is setup like:

combo.Items.AddRange( new object[] { "opt1", "opt2" } );
combo.Name = "whaterver";
... (other display proerties)

Now, here's the thing. When I tray to add a new record through
BindingContext[...].AddNew(), a new record is added in the DataGrid but the
current position is not moved to that record and the contents off all the
textboxes is not cleared...

I've read that a checkbox in a form can cause this problem (a bug) but I
haven't found a way to work arround thisone, I haven't found this exact
problem either though.

Any ideas?

Thanks
Rashmi - 07 Jun 2005 04:13 GMT
Are you trying to do something similar to this example:
http://www.fawcette.com/vsm/2002%5F01/magazine/features/abrust/

I normally create a dataview - and bind it to grid. For adding a new
record - dataview.addnew().

Hope this helps,
Rashmi
Jaime - 07 Jun 2005 04:39 GMT
Yes that's more or less it... I have a datagrid that is bound to a dataset,
that is filled with a dataadapter, now the dataadapter contains all the
commands for select, insert, delete, update. Then the textboxes (that show
the detailed record that is selected in the datagrid) are also bounded using
the same dataset. I'm not using a dataview, just the dataadapter and the
dataset. Now if I don't bind the combo box, everything works fine, but as
soon as I bind it, the problem shows up

Thanks for your answer

> Are you trying to do something similar to this example:
> http://www.fawcette.com/vsm/2002%5F01/magazine/features/abrust/
[quoted text clipped - 4 lines]
> Hope this helps,
> Rashmi
Rashmi - 07 Jun 2005 14:36 GMT
To move to the newly added row you could do something like this:
i = dataset.Tables(tablename).Rows.Count
DataGrid1.CurrentCell = New DataGridCell(i, 0)

Also, Is the combobox bound to any datasource ?
Rashmi - 07 Jun 2005 14:41 GMT
To move to the newly added row you could do something like this:
i = dataset.Tables(tablename).Rows.Count
DataGrid1.CurrentCell = New DataGridCell(i, 0)

Also, Is combobox bound to any datasource?

-Rashmi
Rashmi - 07 Jun 2005 14:48 GMT
Sorry, I did not read your first post carefully. For binding the combo
boxes you can try using "SelectedValue" property , Eg:
combobox.DataBindings.Add("SelectedValue", dataset, "fieldname")

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.