Dear group,
I'm currrently investigating a bug within a piece of our software whereby if
a DataGridView (bound directly to a DataTable) is ordered by column headers
(containing lookup combo boxes where the value is the foreign key of another
table), although the DataGridView is ok, the DataTable becomes out of sync.
In other words, I have a Grid of customers, and if a customer name column
header is clicked - the data moves in the DataGridView, but previous data is
still held for the original row positions in the DataTable.
This throws off row calculations quite considerably, and is a particularly
fustrating bug to debug.
Any ideas are most welcome, and thanks in advance for any advice.
Regards,
Mike 3 2479
Mike,
The datagridview is actually bound to the datatable's defaultview.
That will have the records in the right order.
Ken
----------------------------
"Mike" <nonewrote in message news:uv******** ******@TK2MSFTN GP02.phx.gbl...
Dear group,
I'm currrently investigating a bug within a piece of our software whereby
if a DataGridView (bound directly to a DataTable) is ordered by column
headers (containing lookup combo boxes where the value is the foreign key
of another table), although the DataGridView is ok, the DataTable becomes
out of sync.
In other words, I have a Grid of customers, and if a customer name column
header is clicked - the data moves in the DataGridView, but previous data
is still held for the original row positions in the DataTable.
This throws off row calculations quite considerably, and is a particularly
fustrating bug to debug.
Any ideas are most welcome, and thanks in advance for any advice.
Regards,
Mike
Ken Tucker [MVP] wrote:
Mike,
The datagridview is actually bound to the datatable's defaultview.
That will have the records in the right order.
Ken
----------------------------
"Mike" <nonewrote in message news:uv******** ******@TK2MSFTN GP02.phx.gbl...
Dear group,
I'm currrently investigating a bug within a piece of our software whereby
if a DataGridView (bound directly to a DataTable) is ordered by column
headers (containing lookup combo boxes where the value is the foreign key
of another table), although the DataGridView is ok, the DataTable becomes
out of sync.
In other words, I have a Grid of customers, and if a customer name column
header is clicked - the data moves in the DataGridView, but previous data
is still held for the original row positions in the DataTable.
This throws off row calculations quite considerably, and is a particularly
fustrating bug to debug.
Any ideas are most welcome, and thanks in advance for any advice.
Regards,
Mike
Wow, thanx, that clears something up for me too.
BTW, a way to simply test this would be to add a DataGridView, three
textboxes and a button. Then the following code:
Dim table As New DataTable
Private Sub Form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
Dim row As DataRow
table.Columns.A dd()
row = table.NewRow
table.Rows.Add( row)
row(0) = "A"
row = table.NewRow
table.Rows.Add( row)
row(0) = "B"
DataGridView1.D ataSource = table
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
TextBox1.Text = DataGridView1.I tem(0, 0).Value.ToStri ng
TextBox2.Text = table.Rows(0)(0 ).ToString
TextBox3.Text = table.DefaultVi ew.Item(0)(0).T oString
End Sub
B.
"Brian Tkatch" <Ma***********@ ThePentagon.com wrote in message
news:11******** ************@m7 9g2000cwm.googl egroups.com...
>
Ken Tucker [MVP] wrote:
>Mike,
The datagridview is actually bound to the datatable's defaultview. That will have the records in the right order.
Ahhh, thank you. I think that will solve it.
>---------------------------- "Mike" <nonewrote in message news:uv******* *******@TK2MSFT NGP02.phx.gbl.. .
Dear group,
I'm currrently investigating a bug within a piece of our software
whereby
if a DataGridView (bound directly to a DataTable) is ordered by column
headers (containing lookup combo boxes where the value is the foreign
key
of another table), although the DataGridView is ok, the DataTable
becomes
out of sync.
In other words, I have a Grid of customers, and if a customer name
column
header is clicked - the data moves in the DataGridView, but previous
data
is still held for the original row positions in the DataTable.
This throws off row calculations quite considerably, and is a
particularly
fustrating bug to debug.
Any ideas are most welcome, and thanks in advance for any advice.
Regards,
Mike
Wow, thanx, that clears something up for me too.
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
TextBox1.Text = DataGridView1.I tem(0, 0).Value.ToStri ng
TextBox2.Text = table.Rows(0)(0 ).ToString
TextBox3.Text = table.DefaultVi ew.Item(0)(0).T oString
End Sub
^ Great example too. I'll have to do some recoding tonight. If any MSDN
article authors are reading this; this has got to be somewhere that a LOT of
people trip up on, but very little example documentation alludes to using
the .DefaultView.
Thanks!
Mike This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bob |
last post by:
During a form's development I noticed that when I changed bound dataset
defintions with the dataset designer (for instance adding a column to one),
when I come back and look at the form the ordering of the columns in the
datagridviews has changed. The column order that I designed is totally
different from what I had set using the datagridview column editor.
As far as I'm concerned this is a bug that should be addressed real quick.
its a...
|
by: Bob |
last post by:
Thinking two things,
1- Creating a userControl -yeah you guessed it, a multi column drop down
combobox - I've looked at several articles and did not find what I need, one
that's bindable and that I can use in a datagrid view.
2- Extending the datagridview so that it can be added to the list in the
column types when editing columns in the datagridview.
I'm really getting PO'd at Microsoft for not including a multi column
combobox both a...
|
by: sklett |
last post by:
I'm changing from a DataGrid to a DataGridView and have run across a
problem. The items that are bound to the DataGrid have an int Property that
represents a primary key of a lookup table in my database. For example:
table JobTypes
1 | Manager
2 | Controller
3 | Supervisor
table Employee
|
by: cris.b |
last post by:
Hi, I have a question about ordering column in a DataGridView.
I have a databound DataGridView with the AutoGenerateColumn property
set to true.
I want to change column's order.
At runtime I change the DisplayIndex property of each column but seems
it doesn't work!
Column's order is not set!
How to do this?
|
by: Martin |
last post by:
Hi all,
This is the situation...
DatagridView Control with datasource set to datatable.
I want the user to be able to delete x number of rows by selecting a row
with mouse then clicking a 'delete' button.
Then user clicks a 'Commit' button to update the database.
| |
by: twq |
last post by:
hello
I have a datagridview in which one column is a datagridCombobox Column
which is data bound, in the second column the user is allowed to
enter what ever he wants, and i want the user to add rows via a
context menu only, i get an error message that rows can not be
programmatically added if control is databound, are there any
workarounds?
thanks
|
by: =?Utf-8?B?Q2hyaXM=?= |
last post by:
how do you insert a new row to a databound datagridview? It won't allow this
action.
|
by: sklett |
last post by:
I've got a strange situation here. I have a databound DataGridView that
also has un-bound columns. When the view loads, I want to update the values
of the unbound columns. If I attempt to modify the unbound column's cells
in the OnLoad() handler the results are very strange. If I add a button to
my view and update the unbound cells in the butt's handler it works fine.
Here is an example of the code I'm trying to use (it's test code):...
|
by: =?Utf-8?B?TG9zdEluTUQ=?= |
last post by:
Hi All :)
I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView.
True DBGrid has a MultipleLines property that controls whether individual
records span multiple lines. Is there an equivalent property for the
DataGridView? I have searched, but have not found one.
I would like the user to be able to see all the columns of the table on one
screen - thus eliminating the need to use the horizontal scroll bar to view...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: 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: 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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
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...
| |