473,387 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

DataGrid / DataTable event problem

The following assumes a System.Windows.Forms.DataGrid with a System.Data.DataTable set as the DataSource. I'm programming in C#

Here's my scenario

I click in a cell on a DataGrid. I enter some text. Before changing to another cell in the DataGrid, I move my mouse pointer off the DataGrid and change the selected item in a ListBox or TreeView.

Here's my question

Which should fire first, the DataTable's RowChanged/CellChanged event or the event indicating the selected node/item has changed in the TreeView/ListBox control

Here's what is happening

If I change the selected item in the Listbox, the DataTable's RowChanged/CellChanged events fire BEFORE the ListBox's SelectedValueChanged event

If I change the selected node in the TreeView, the DataTable's RowChanged/CellChanged events fire AFTER the TreeView's AfterSelected event

For starters, these event orderings seem inconsistent with each other

Here's my problem

My TreeView is controlling what is displayed in my DataGrid (and what populates the underlying DataTable). When I enter something in a DataGrid cell, then change the selected node in my TreeView without first changing the cell in my DataGrid to force an update, I don't get to handle the RowChanged/CellChanged event until AFTER I've updated the DataSource for the DataGrid to a different DataTable that corresponds the newly selected tree node. I've got an old DataTable throwing the event that no longer matches the context I'm in, which is defined by the node selected in the TreeView

In Summary

Users have to change to a different cell every time they make a change in the DataGrid or they lose their change if they change what's loaded into the DataGrid by selecting a different node in the tree. (Or even if they save--I'm presented with a related problem when they click on a toolbar button or menu item to save the changes they've made to the data in the grid--they lose what's in the current cell

Is there a straightforward way around this problem? I've tried programatically changing the cell in the DataGrid to force an update as a hack to get by this, but had no success with that. Can anyone tell me how this was designed to be used, or a good way around this problem

Thanks in advance for any help!
Nov 16 '05 #1
0 3121

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Emerson | last post by:
The following assumes a System.Windows.Forms.DataGrid with a System.Data.DataTable set as the DataSource. I'm programming in C# Here's my scenario I click in a cell on a DataGrid. I enter some...
7
by: localhost | last post by:
A DataGrid with shows a label in one of the columns when in view mode. When in edit mode, I want to show a dropdown, and have the default selection set to what the textbox used to be. Right now...
1
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple...
0
by: Steve | last post by:
I have a datagrid that is created at run time DataGrid dgG = new DataGrid(); BoundColumn bcB; dgG.CellPadding = 5; dgG.CellSpacing = 0; dgG.GridLines = GridLines.Both; dgG.CssClass =...
4
by: The Alchemist | last post by:
I am having a problem with a dynamically-generated Datagrid. It is important to point out that this problem does not exist with a design-time created Datagrid, but only with a dynamically generated...
2
by: Ben | last post by:
Hi, I'd like to have a datagrid that has a dropdownlist in the pager control for setting the page size. I can get the control into the pager inside the datagrid itemcreated event by checking for...
4
by: KB | last post by:
I realised that if I use datagrid and datasource is a datatable, when I created a new row and while on that row I exit the datagrid (ie. without moving into the next row) and focus onto another...
0
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string...
10
by: amiga500 | last post by:
Hello, I have one basic simple question. When I have multiple records in the datagrid as follows: Code Product 1 Product 2 Product 3 11111 A B C...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.