(I posted this in a databinding NG, but it's a VERY low traffic NG so I
thought I would post here as well. I hope no one minds too much, if you do
I'm sorry)
I have a DGV that is bound to a DataTable that is loaded during application
startup. I can sort with all the columns and everything works fine. I have
a method that can be invoked from a context menu that will loop through the
rows of the bound table and modify a specific cell in each row. After
modifying the rows sorting doesn't work for that column anymore.
To give a more familiar example:
Load the Products table from the Northwind DB
Bind to a DGV via a BindingSource object
Test teh sorting by clicking on the DGV columns
add a button and in the click handler, loop through the DataRow collection
and set the ProductID column to the value using an int that increments in
the loop.
Try and sort the ProductID column.
You will get incorrect results, it will sort 20 or so rows, then jump to
another number, then jump again.. it's broken.
I've tried everything I can think of:
calling EndEdit on each row
reseting bindings
etc
Nothing seems to solve it. I'm not one to cry "bug" but this sure seems
like one to me.
Anyone ever experience this? Anyone happen to have a demo application setup
with Northwind they could quickly check this? I've spent over a week now
trying to find the problem and I can't. :(
Any help or input greatly appreciated!
Thanks for reading,
Steve 4 1676
Have you tried re-binding the DGV after you have revised the datasource?
Also, Datatable has a DefaultView property which sports a Sort property that
you can set, and then bind to the View instead of the table.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"sklett" wrote:
(I posted this in a databinding NG, but it's a VERY low traffic NG so I
thought I would post here as well. I hope no one minds too much, if you do
I'm sorry)
I have a DGV that is bound to a DataTable that is loaded during application
startup. I can sort with all the columns and everything works fine. I have
a method that can be invoked from a context menu that will loop through the
rows of the bound table and modify a specific cell in each row. After
modifying the rows sorting doesn't work for that column anymore.
To give a more familiar example:
Load the Products table from the Northwind DB
Bind to a DGV via a BindingSource object
Test teh sorting by clicking on the DGV columns
add a button and in the click handler, loop through the DataRow collection
and set the ProductID column to the value using an int that increments in
the loop.
Try and sort the ProductID column.
You will get incorrect results, it will sort 20 or so rows, then jump to
another number, then jump again.. it's broken.
I've tried everything I can think of:
calling EndEdit on each row
reseting bindings
etc
Nothing seems to solve it. I'm not one to cry "bug" but this sure seems
like one to me.
Anyone ever experience this? Anyone happen to have a demo application setup
with Northwind they could quickly check this? I've spent over a week now
trying to find the problem and I can't. :(
Any help or input greatly appreciated!
Thanks for reading,
Steve
Thank you for the reply Peter,
Yes, my mistake, I am binding to the DataTable.DefaultView and also
specifying the Sort string via the DataTable.DefaultView.Sort property.
I'm checked the the DefaultView is sorting correctly and it is, if I print
out the values to the console everything is correct, but once the DGV
displays the items it makes a mess of it all.
very strange.
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:CA**********************************@microsof t.com...
Have you tried re-binding the DGV after you have revised the datasource?
Also, Datatable has a DefaultView property which sports a Sort property
that
you can set, and then bind to the View instead of the table.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"sklett" wrote:
>(I posted this in a databinding NG, but it's a VERY low traffic NG so I thought I would post here as well. I hope no one minds too much, if you do I'm sorry)
I have a DGV that is bound to a DataTable that is loaded during application startup. I can sort with all the columns and everything works fine. I have a method that can be invoked from a context menu that will loop through the rows of the bound table and modify a specific cell in each row. After modifying the rows sorting doesn't work for that column anymore.
To give a more familiar example: Load the Products table from the Northwind DB Bind to a DGV via a BindingSource object Test teh sorting by clicking on the DGV columns add a button and in the click handler, loop through the DataRow collection and set the ProductID column to the value using an int that increments in the loop. Try and sort the ProductID column.
You will get incorrect results, it will sort 20 or so rows, then jump to another number, then jump again.. it's broken.
I've tried everything I can think of: calling EndEdit on each row reseting bindings etc
Nothing seems to solve it. I'm not one to cry "bug" but this sure seems like one to me.
Anyone ever experience this? Anyone happen to have a demo application setup with Northwind they could quickly check this? I've spent over a week now trying to find the problem and I can't. :(
Any help or input greatly appreciated!
Thanks for reading, Steve
If you are using .Net 2.0, you might try putting a BindingSource between
your data source and your DGV, and using that to sort.
BindingSource myBindingSource = new BindingSource();
myBindingSource.DataSource = myDataTable;
myDataGridView.DataSource = myBindingSource;
Any changes you make to the underlying data source are immediately
displayed to the bound control via the BindingSource. It's kind like
lubrication in a bunch of gears. And you can do sorts and filters and all
kinds of things with the BindingSource.
Robin S.
--------------------------------------
"sklett" <s@s.comwrote in message
news:Ob**************@TK2MSFTNGP06.phx.gbl...
Thank you for the reply Peter,
Yes, my mistake, I am binding to the DataTable.DefaultView and also
specifying the Sort string via the DataTable.DefaultView.Sort property.
I'm checked the the DefaultView is sorting correctly and it is, if I
print out the values to the console everything is correct, but once the
DGV displays the items it makes a mess of it all.
very strange.
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:CA**********************************@microsof t.com...
>Have you tried re-binding the DGV after you have revised the datasource? Also, Datatable has a DefaultView property which sports a Sort property that you can set, and then bind to the View instead of the table. Peter
-- Site: http://www.eggheadcafe.com UnBlog: http://petesbloggerama.blogspot.com Short urls & more: http://ittyurl.net
"sklett" wrote:
>>(I posted this in a databinding NG, but it's a VERY low traffic NG so I thought I would post here as well. I hope no one minds too much, if you do I'm sorry)
I have a DGV that is bound to a DataTable that is loaded during application startup. I can sort with all the columns and everything works fine. I have a method that can be invoked from a context menu that will loop through the rows of the bound table and modify a specific cell in each row. After modifying the rows sorting doesn't work for that column anymore.
To give a more familiar example: Load the Products table from the Northwind DB Bind to a DGV via a BindingSource object Test teh sorting by clicking on the DGV columns add a button and in the click handler, loop through the DataRow collection and set the ProductID column to the value using an int that increments in the loop. Try and sort the ProductID column.
You will get incorrect results, it will sort 20 or so rows, then jump to another number, then jump again.. it's broken.
I've tried everything I can think of: calling EndEdit on each row reseting bindings etc
Nothing seems to solve it. I'm not one to cry "bug" but this sure seems like one to me.
Anyone ever experience this? Anyone happen to have a demo application setup with Northwind they could quickly check this? I've spent over a week now trying to find the problem and I can't. :(
Any help or input greatly appreciated!
Thanks for reading, Steve
Hi Robin,
Thank you for the reply. I have tried a BindingSource, it didn't make a
difference, same exact behavior :(
Have a good weekend,
Steve
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:NK******************************@comcast.com. ..
If you are using .Net 2.0, you might try putting a BindingSource between
your data source and your DGV, and using that to sort.
BindingSource myBindingSource = new BindingSource();
myBindingSource.DataSource = myDataTable;
myDataGridView.DataSource = myBindingSource;
Any changes you make to the underlying data source are immediately
displayed to the bound control via the BindingSource. It's kind like
lubrication in a bunch of gears. And you can do sorts and filters and all
kinds of things with the BindingSource.
Robin S.
--------------------------------------
"sklett" <s@s.comwrote in message
news:Ob**************@TK2MSFTNGP06.phx.gbl...
>Thank you for the reply Peter,
Yes, my mistake, I am binding to the DataTable.DefaultView and also specifying the Sort string via the DataTable.DefaultView.Sort property.
I'm checked the the DefaultView is sorting correctly and it is, if I print out the values to the console everything is correct, but once the DGV displays the items it makes a mess of it all. very strange.
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in message news:CA**********************************@microsof t.com...
>>Have you tried re-binding the DGV after you have revised the datasource? Also, Datatable has a DefaultView property which sports a Sort property that you can set, and then bind to the View instead of the table. Peter
-- Site: http://www.eggheadcafe.com UnBlog: http://petesbloggerama.blogspot.com Short urls & more: http://ittyurl.net
"sklett" wrote:
(I posted this in a databinding NG, but it's a VERY low traffic NG so I thought I would post here as well. I hope no one minds too much, if you do I'm sorry)
I have a DGV that is bound to a DataTable that is loaded during application startup. I can sort with all the columns and everything works fine. I have a method that can be invoked from a context menu that will loop through the rows of the bound table and modify a specific cell in each row. After modifying the rows sorting doesn't work for that column anymore.
To give a more familiar example: Load the Products table from the Northwind DB Bind to a DGV via a BindingSource object Test teh sorting by clicking on the DGV columns add a button and in the click handler, loop through the DataRow collection and set the ProductID column to the value using an int that increments in the loop. Try and sort the ProductID column.
You will get incorrect results, it will sort 20 or so rows, then jump to another number, then jump again.. it's broken.
I've tried everything I can think of: calling EndEdit on each row reseting bindings etc
Nothing seems to solve it. I'm not one to cry "bug" but this sure seems like one to me.
Anyone ever experience this? Anyone happen to have a demo application setup with Northwind they could quickly check this? I've spent over a week now trying to find the problem and I can't. :(
Any help or input greatly appreciated!
Thanks for reading, Steve This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ruby Tuesday |
last post by:
Hi, may be some of you MySQL database guru can shed me some lite to do the
following:
I have rows of data in mysql as follow:
CODES
=====
HH-1
....
HH-1000
|
by: Gerry Sutton |
last post by:
Hi All!
I have noticed a strange behavior when using a constant identifier to
initialize an instance list variable in a base class and then trying to
modifying the list in subclasses by using...
|
by: Tom Hughes |
last post by:
I want to change one field of all selected rows to a provided value.
Problem 1
I am using the Binding Manager Base to bind the datagrid to the
appropriate dataTable as recommended by KB817247....
|
by: Dave Elliott |
last post by:
After inserting a new data row to a DataTable that is bound to a
datagrid, I am unable to change data in a row that is after the newly
added row without getting bizarre results.
I have added the...
|
by: Bruce Pullum |
last post by:
I have a datagrid that I am using a DataView with. All works great for the
sorting of the columns. However, after I sort the column, and then try and
select a data row to edit, the row selected...
|
by: |
last post by:
Is there an event that is invoked when a user sorts a
column in a Windows Forms DataGrid?
I have context senstive icons that are enabled\disabled
depending upon the selected item in the...
|
by: Bill Todd |
last post by:
In a WinForms application with a DataGrid bound to a DataTable, if I
change the DefaultDataView.Sort property the order of the data in the
grid does not change.
If I change the Sort property...
|
by: thebison |
last post by:
Hi all,
I hope someone can help with this relatively simple problem.
I am building a timesheet application using ASP.NET C# with Visual
Studio 2003.As it is only a protoype application, my...
|
by: Frederik |
last post by:
Hi group,
I have a DataGridView that is mainly consisting of data bound columns.
One column however is unbound. I'm not able to sort the grid on this
column! Is that normal behaviour? If so,...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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,...
|
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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...
| |