Hi there - I hope someone out there can help me! I'm using a .Net DataGrid
Class to show the results of a SQL query in a spreadsheet type control. The
code, which works fine is:
iRowCount = oleDbDataAdapte r1->Fill(dataSet1) ;
dataGrid1->DataSource = dataSet1->Tables->Item[0]->DefaultView;
I then update the underlying data in the database elsewhere in the code by
adding
some new rows and
want the datagrid control to show the updated and new rows correctly. I do a
refresh
to ensure the dataSet is up-to-date with the following statement:
iRowCount = oleDbDataAdapte r1->Fill(dataSet1) ;
and having checked the iRowCount value I know that the dataSet has
definitely got the new rows.
So, the question is, how do I get the DataGrid to show the updated data on
the screen? There doesn't appear to be a Reload / Rebind type method in the
System.Windows. Forms.DataGrid Class. The Refresh() method doesn't do it. Any
help will be most appreciated!
Cheers 5 2071
Hi Sanddevil,
"Sanddevil" <sa*******@amlo r.demon.co.uk> schreef in bericht
news:d5******** ***********@new s.demon.co.uk.. . Hi there - I hope someone out there can help me! I'm using a .Net DataGrid Class to show the results of a SQL query in a spreadsheet type control. The code, which works fine is:
iRowCount = oleDbDataAdapte r1->Fill(dataSet1) ;
dataGrid1->DataSource = dataSet1->Tables->Item[0]->DefaultView;
I then update the underlying data in the database elsewhere in the code by adding some new rows and want the datagrid control to show the updated and new rows correctly. I do a refresh to ensure the dataSet is up-to-date with the following statement:
iRowCount = oleDbDataAdapte r1->Fill(dataSet1) ;
and having checked the iRowCount value I know that the dataSet has definitely got the new rows.
So, the question is, how do I get the DataGrid to show the updated data on the screen? There doesn't appear to be a Reload / Rebind type method in the System.Windows. Forms.DataGrid Class. The Refresh() method doesn't do it. Any help will be most appreciated!
Although I'm not sure, I think "Invalidate " method could do that. What I
also think is that there is probably still a better way, but I never did
what you do. Invalidate actually forces the control to repaint itself.
Another thing I haven't tested but that might work, is to use the
SuspendBinding and ResumeBinding methods of the BindingManager of your grid.
Call SuspendBinding before modifying the DataSet and ResumeBinding after
that. You can retrieve the BindingManager using the BindingContext property
of your DataGrid:
BindingManagerB ase bm;
bm = dataGrid.Bindin gContext[ dataGrid.DataSo urce,
dataGrid.DataMe mber ];
bm.SuspendBindi ng();
// update data
bm.ResumeBindin g();
An interesting FAQ that might help you further is http://msdn.microsoft.com/smartclien...q/default.aspx (main
page)
and in specific http://msdn.microsoft.com/smartclien...aq/ctrlsp.aspx
Kind regards,
Tom T.
"TT (Tom Tempelaere)" </\/_0_$P@/\/\titi____AThotm ailD.Tcom/\/\@P$_0_/\/>
schreef in bericht news:p3******** ************@ph obos.telenet-ops.be...
[...] Another thing I haven't tested but that might work, is to use the SuspendBinding and ResumeBinding methods of the BindingManager of your grid. Call SuspendBinding before modifying the DataSet and ResumeBinding after that. You can retrieve the BindingManager using the BindingContext property of your DataGrid:
BindingManagerB ase bm; bm = dataGrid.Bindin gContext[ dataGrid.DataSo urce, dataGrid.DataMe mber ]; bm.SuspendBindi ng(); // update data bm.ResumeBindin g();
[...]
This example uses C#, just to mention... But it should be similar in MC++
TT
Hi Tom - many thanks for taking the trouble to respond to me. It was much
appreciated, and your suggestion worked!
The syntax was a little tricky in C++, so for the benfit of anyone stumbling
upon this in the future:
BindingManagerB ase* pBm;
pBm = dataGrid1->BindingConte xt->Item[dataGrid1->DataSource,
dataGrid1->DataMember];
pBm->SuspendBinding ();
// Do your updates to the underlying database here
pBm->ResumeBinding( );
Many thanks again.
Cheers
Sanddevil
"TT (Tom Tempelaere)" </\/_0_$P@/\/\titi____AThotm ailD.Tcom/\/\@P$_0_/\/>
wrote in message news:47******** ************@ph obos.telenet-ops.be... "TT (Tom Tempelaere)" </\/_0_$P@/\/\titi____AThotm ailD.Tcom/\/\@P$_0_/\/> schreef in bericht news:p3******** ************@ph obos.telenet-ops.be... [...] Another thing I haven't tested but that might work, is to use the SuspendBinding and ResumeBinding methods of the BindingManager of your grid. Call SuspendBinding before modifying the DataSet and ResumeBinding after that. You can retrieve the BindingManager using the BindingContext property of your DataGrid:
BindingManagerB ase bm; bm = dataGrid.Bindin gContext[ dataGrid.DataSo urce, dataGrid.DataMe mber ]; bm.SuspendBindi ng(); // update data bm.ResumeBindin g(); [...]
This example uses C#, just to mention... But it should be similar in MC++
TT
Way to go Sanddevil...
TT
"Sanddevil" <sa*******@amlo r.demon.co.uk> schreef in bericht
news:d5******** ***********@new s.demon.co.uk.. . Hi Tom - many thanks for taking the trouble to respond to me. It was much appreciated, and your suggestion worked!
The syntax was a little tricky in C++, so for the benfit of anyone stumbling upon this in the future:
BindingManagerB ase* pBm;
pBm = dataGrid1->BindingConte xt->Item[dataGrid1->DataSource, dataGrid1->DataMember];
pBm->SuspendBinding ();
// Do your updates to the underlying database here
pBm->ResumeBinding( );
Many thanks again. Cheers Sanddevil "TT (Tom Tempelaere)" </\/_0_$P@/\/\titi____AThotm ailD.Tcom/\/\@P$_0_/\/> wrote in message news:47******** ************@ph obos.telenet-ops.be... "TT (Tom Tempelaere)" </\/_0_$P@/\/\titi____AThotm ailD.Tcom/\/\@P$_0_/\/> schreef in bericht news:p3******** ************@ph obos.telenet-ops.be... [...] > Another thing I haven't tested but that might work, is to use the > SuspendBinding and ResumeBinding methods of the BindingManager of your > grid. Call SuspendBinding before modifying the DataSet and > ResumeBinding > after that. You can retrieve the BindingManager using the > BindingContext > property of your DataGrid: > > BindingManagerB ase bm; > bm = dataGrid.Bindin gContext[ dataGrid.DataSo urce, > dataGrid.DataMe mber ]; > bm.SuspendBindi ng(); > // update data > bm.ResumeBindin g(); [...]
This example uses C#, just to mention... But it should be similar in MC++
TT
In fact, I've come across another solution which I'll preserve here for
prosterity in case others need it.
This solution involves clearing the dataset and then reloading it. No
performance issues either - on my creaky old laptop it is a blink of an eye.
// Load the grid
iRowCount = oleDbDataAdapte r1->Fill(dataSet1) ;
dataGrid1->DataSource = dataSet1->Tables->Item[0]->DefaultView;
// add / amend rows in the underlying database elsewhere in the code
// update the screen
dataSet1->Clear();
iRowCount = oleDbDataAdapte r1->Fill(dataSet1) ;
Cheers
Sanddevil
"TT (Tom Tempelaere)" </\/_0_$P@/\/\titi____AThotm ailD.Tcom/\/\@P$_0_/\/>
wrote in message news:Ap******** *************@p hobos.telenet-ops.be... Way to go Sanddevil...
TT This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tamlin |
last post by:
Hi all,
I'm getting a bug with the datagrid object.
I've created one from scratch, bound it to a dataview with 2 int32
columns and formatted the output as currency.
I've found that when you use the F2 key to enter edit mode and then
hit TAB or ESCAPE without actually editing the value, dotnet crashes
with a null reference error.
|
by: SammyBar |
last post by:
Hi,
I'm trying to bind a custom collection class to a data grid, following the
guidelines from the article
http://msdn.microsoft.com/msdnmag/issues/05/08/CollectionsandDataBinding/default.aspx.
The problem is the article is in VisualBasic. I already get the collection
to be recognized as a Data Source by the IDE. It populated the DataGrid
correctly from the fields on the items object of the collection, but I can't
get the DataGrid to...
|
by: Morné |
last post by:
Hi
how do I validate a text value in a datagrid e.g. the user is only
allowed to type in a Y or a N. I specifically have a problem with
using the PropertyDescriptorCollection. I get the following error:
"Additional information: Cannot create a child list for field Query."
Below my existing code:
|
by: Bill C. |
last post by:
Hello,
I know this has been discussed a lot already because I've been searching
around for information the last few weeks.
I'm trying to implement a DataGridComboBoxColumn class. I've found
several examples on the web. They all seem to have problems, though
that I've been unable to resolve.
The most promising example I have found is at:
|
by: Mauro |
last post by:
Hi,
I need a big help to resolve this problem.
I need to put a usercontrol in a datagrid: this control check if the code
inserted is present in a archive and if not return a error message.
(In the example I have changed this check with a easy "if string is empty" )
Everything would be easy if the datagrid had a predictable behaviour.
I explain my problem.
| |
by: Raj |
last post by:
Hi,
When we are sorting the DataGrid Boolean column the grid is becoming
redcross.
I have my own PPMIPDataGridBoolColumn class inherited from
System.Windows.Forms.DataGridBoolColumn. In this inherited class I have one
DataGridValueChangedEventHandler event handler. I am overriding Edit() to
know the current state of the cell. I am overriding Paint() to know the if
the user has been editing the cell. I am also overriding the Commit() to
|
by: Ryan Liu |
last post by:
Hi there,
I got a NullReferenceException when delete last row in a datagrid.
I had hard time to solve since it does not occur in my own code.
I put a datagrid in my inherited user control, then put this control on a
form.
I use DataAdaptor to fill the data table and update database.
|
by: Genojoe |
last post by:
I am using code from Help with two exceptions. (1) I increased the number of sample rows from 3 to 20, and (2) I anchored the datagrid to bottom of form so that I can change the size of the grid by changing the size of the form
The code is at the following location in the January, 2004 help
ms-help://MS.VSCC.2003/MS.MSDNQTR.2004JAN.1033/cpref/html/frlrfSystemWindowsFormsDataGridClassTopic.ht
You can also find it by doing a search for...
|
by: pmcguire |
last post by:
I have a DataGrid control for which I have also created several new extended
DataGridColumnStyles. They behave pretty nicely, but I can't figure out how
to implement Selected Item formatting for them.
In a plain vanilla DataGrid, when you click on the RowHeader, the
appropriate row changes colors. I ASSUME this should be done in the Paint
(or PaintText) override of the DataGridColumnStyle in question. My problem
is that I don't know...
|
by: JamesOo |
last post by:
I have the code below, but I need to make it searchable in query table,
below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only, cannot serch by combine 3 table)
Example I have the query table below, how do I make the code to seach based on the query from this:
SELECT Product.ID, Product.Description, Quantity.Quantity, Quantity.SeialNo, Quantity.SupplierID,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |