Wrox Programmer Forums
|
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 16th, 2003, 10:19 AM
Registered User
 
Join Date: Jun 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Windows Forms DataGrid .NET

Hi!

I have a problem with the Datagrid.
It is easily reproducable using the VS.NET Data Form wizard:

1) With the wizard, generate a Master-
detail application againt the Microsoft 'pubs' database.
2) Use the publishers and titles tables, and tell the
wizard to show both the master and the detail records in a
grid.
3) Make sure, that the Allow_Navigation property of the
Master grid is set to true.

4) Run the application. Add a new row to the publishers,
for example pub_id=9910,...
5) Without clicking on another master record, navigate to
the child record of the newly created master record.
6) You'll notice, that the pub_id field of the new titles
record is null, and not set to 9910.
   (The same if you go to the titles grid.)

1) Terminate the appl. and set the DataSource property of the
titles grid (child grid) to none.
2) Rerun the application and repeat the above scenario:
You'll see that now the pub_id field of the new titles
record is properly initialized to 9910.

Can somebody tell me, how to get around this problem? (Is
there a bug somewhere or do I miss something?)

Thank you!
Antal Pak
 
Old June 19th, 2003, 01:33 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

This isn't really a "bug".. It's just unexpected behavior..

I assume that you are making the change OUTSIDE of the grid- therefore the grid doesn't know it needs to update the information.

You must rebind a databound control to it's datasource after you change the data outside of the control itself.

Hal Levy
Daddyshome, LLC
NOT a Wiley/Wrox Employee
 
Old June 20th, 2003, 08:09 AM
Registered User
 
Join Date: Jun 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi!

I did not make the changes outside of the master grid. I just entered a new record into the master grid and then clicked on the 1st row of the detail grid.

Anyway, I have just found a solution for my problem:

I have added the following GotFocus event handler for the detail grid which seems to work just fine:

 this.grdtitles.GotFocus += new System.EventHandler(this.OnGotFocus);
 ...
 private void OnGotFocus(object sender, System.EventArgs e)
  {
    CurrencyManager cm = (CurrencyManager)this.BindingContext[objdsPublishersTitles,"publishers"];
            cm.Refresh();
  }

Thank you,
Antal





Similar Threads
Thread Thread Starter Forum Replies Last Post
windows forms datagrid - refresh ab_dev General .NET 0 March 1st, 2006 06:37 PM
VC++ .NET 2003 Windows Forms Designer Problem alphatrak General .NET 0 February 15th, 2006 08:44 PM
How Do I SHOW and HIDE Windows Forms in VB.NET? kegeorge0819 VB How-To 1 March 10th, 2005 03:49 AM
Windows Forms datagrid column backcolor dbradley VB.NET 3 April 6th, 2004 11:43 AM
C# Windows Forms in VS.Net rb157 VS.NET 2002/2003 0 January 10th, 2004 06:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.