I've got a problem, i got the nodes to move but
1. they copy nodes(if you drag it to 3 different places it will actually have 3 of the same nodes)
2. i want to make the nodes, if moved update the new nodes locations
This is my coding -
private void tvDescriptions_MouseDown(object sender, MouseEventArgs e)
-
{
-
TreeView tree = (TreeView)sender;
-
-
// Get the node underneath the mouse.
-
TreeNode node = tree.GetNodeAt(e.X, e.Y);
-
-
// Start the drag-and-drop operation with a cloned copy of the node.
-
if (node != null)
-
{
-
tree.DoDragDrop(node.Clone(), DragDropEffects.Copy);
-
}
-
}
-
-
private void tvDescriptions_DragOver(object sender, DragEventArgs e)
-
{
-
// Get the tree.
-
TreeView tree = (TreeView)sender;
-
-
// Drag and drop denied by default.
-
e.Effect = DragDropEffects.None;
-
-
// Is it a valid format?
-
if (e.Data.GetData(typeof(TreeNode)) != null)
-
{
-
// Get the screen point.
-
Point pt = new Point(e.X, e.Y);
-
-
// Convert to a point in the TreeView's coordinate system.
-
pt = tree.PointToClient(pt);
-
-
// Is the mouse over a valid node?
-
TreeNode node = tree.GetNodeAt(pt);
-
if (node != null)
-
{
-
e.Effect = DragDropEffects.Copy;
-
tree.SelectedNode = node;
-
}
-
}
-
}
-
-
private void tvDescriptions_DragDrop(object sender, DragEventArgs e)
-
{
-
// Get the tree.
-
TreeView tree = (TreeView)sender;
-
-
// Get the screen point.
-
Point pt = new Point(e.X, e.Y);
-
-
// Convert to a point in the TreeView's coordinate system.
-
pt = tree.PointToClient(pt);
-
-
// Get the node underneath the mouse.
-
TreeNode node = tree.GetNodeAt(pt);
-
-
// Add a child node.
-
node.Nodes.Add((TreeNode)e.Data.GetData(typeof(TreeNode)));
-
-
// Show the newly added node if it is not already visible.
-
node.Expand();
-
}
-
-
private void tvDescriptions_ItemDrag(object sender, ItemDragEventArgs e)
-
{
-
-
}
-
6 4057 tlhintoq 3,525
Recognized Expert Specialist
So you want a 'move' not a copy? Am I reading that right?
Do the copy, then at the node where you moved it from perform a .Remove
At line 6 you learn which node is being copied (naming it 'node')
between lines 11 and 12 add... tree.Nodes.Remo ve(node);
Thanx, you really know your stuff. How or where will i post a event to update the database with the new information?
tlhintoq 3,525
Recognized Expert Specialist
where will i post a event to update the database with the new information?
I don't know your program as well as you do, so I can only give you a generic answer... I would raise and event to perform an update after I'm done with all my changes. Where that fits into what you've engineered, only you know. This treeview could be on its own user control, or it could be on a floating pallet or it could be in the middle of your one and only form. I can't say. But that's the beauty of events... As long as you have another class 'listening' (subscribed) to the event it will still work.
Hi,
this is my coding. I get a error that states "Must use a updatable query" and if you double click on the nodes the whole program freezes. any help? - private void tvLocations_MouseDown(object sender, MouseEventArgs e)
-
{
-
TreeView tree = (TreeView)sender;
-
-
// Get the node underneath the mouse.
-
TreeNode node = tree.GetNodeAt(e.X, e.Y);
-
-
// Start the drag-and-drop operation with a cloned copy of the node.
-
if (node != null)
-
{
-
tree.DoDragDrop(node, DragDropEffects.Copy);
-
//node.Remove();
-
-
}
-
}
-
-
private void tvLocations_DragOver(object sender, DragEventArgs e)
-
{
-
// Get the tree.
-
TreeView tree = (TreeView)sender;
-
-
-
// Drag and drop denied by default.
-
e.Effect = DragDropEffects.None;
-
-
// Is it a valid format?
-
if (e.Data.GetData(typeof(TreeNode)) != null)
-
{
-
// Get the screen point.
-
Point pt = new Point(e.X, e.Y);
-
-
// Convert to a point in the TreeView's coordinate system.
-
pt = tree.PointToClient(pt);
-
-
// Is the mouse over a valid node?
-
TreeNode node = tree.GetNodeAt(pt);
-
if (node != null)
-
{
-
e.Effect = DragDropEffects.Copy;
-
tree.SelectedNode = node;
-
-
}
-
}
-
}
-
-
private void tvLocations_DragDrop(object sender, DragEventArgs e)
-
{
-
try
-
{
-
// Get the tree.
-
TreeView tree = (TreeView)sender;
-
-
tree.BeginUpdate();
-
-
// Get the screen point.
-
Point pt = new Point(e.X, e.Y);
-
-
// Convert to a point in the TreeView's coordinate system.
-
pt = tree.PointToClient(pt);
-
-
// Get the node underneath the mouse.
-
TreeNode node = tree.GetNodeAt(pt);
-
-
TreeNode childNode = (TreeNode)e.Data.GetData(typeof(TreeNode));
-
-
// Remoce this node
-
tree.Nodes.Remove(childNode);
-
-
// Add the node to the new parent
-
node.Nodes.Add(childNode);
-
-
// Show the newly added node if it is not already visible.
-
node.Expand();
-
-
tree.EndUpdate();
-
-
UpdateDBStructure(childNode.Tag, node.Tag);
-
}
-
catch (Exception ex)
-
{
-
MessageBox.Show("Error: " + ex.Message);
-
}
-
}
-
-
private void tvLocations_ItemDrag(object sender, ItemDragEventArgs e)
-
{
-
-
}
-
-
private void UpdateDBStructure(object Id, object parentId)
-
{
-
OleDbConnection mConn = new OleDbConnection(strCon);
-
-
mConn.Open();
-
-
string UpdateStr = @"UPDATE qx_AssetLocation SET
-
alc__acl_id = " + parentId +
-
" where alc__ID = " + Id;
-
-
OleDbCommand myCmd = mConn.CreateCommand();
-
myCmd.CommandText = UpdateStr;
-
try
-
{
-
myCmd.ExecuteNonQuery();
-
//MessageBox.Show("Data added to database");
-
-
}
-
catch (Exception ed)
-
{
-
MessageBox.Show("Error: " + ed.Message, "Error");
-
}
-
finally
-
{
-
myCmd.Dispose();
-
mConn.Close();
-
mConn.Dispose();
-
tvLocations.Nodes.Clear();
-
//PopulateTree();
-
}
-
-
-
}
tlhintoq 3,525
Recognized Expert Specialist
Put a breakpoint in your UpdateDbStructu re (line 92 or so) and walk through it one step at a time with F-10. See if that helps you find the exact location and nature of the issue.
thanx man for the help, things are working
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: alanrn |
last post by:
I am using a TreeView to display the hierarchy of a strongly-typed collection
(inherited from CollectionBase). The order of the nodes in the TreeView is
strictly tied to the order in which they appear in the underlying collection.
However, the user must be able to reorder certain items in the
collection--and, hence, the TreeView.
I have created a context-sensitive menu that allows the user to move an item
in the collection either up or...
|
by: ewosch |
last post by:
Hi,
is there a possibility to move a node from one child position to
another ?
thanks
Wolfgang
|
by: Victor |
last post by:
I need to move a node to different position at the same level. Internet
explorer does very intiutive using a line where the node should be inserted:
-How a line may be presented between nodes indicating the position to insert?
-How to get the nodes (node up and down the cursor position)?
Thanks
Victor
|
by: Victor |
last post by:
I need to move a node to different position but at the same level.
Internet explorer does very intiutive presenting a line where the node
should be inserted (when you want insert between two nodes no under a node).
Have you got an example.
Thanks
Victor
|
by: db2udbgirl |
last post by:
When I installed DB2 UDB 8.2 on AIX 5.3 it got installed in
/home/db2inst1 (and I didn't care about it much then but now I would
like to move the same instance of DB2 to a dedicated filesystem. May I
know the steps involved in doing this migration activity.
Thanks,
db2udbgirl
| |
by: hari60133 |
last post by:
In single/double linked list having 10 nodes due to some memory problems the 4th next node is pointing to 3rd node not to a 5 th node, how to findout the 5th node?
please explain concept and send code .
|
by: Bart Steur |
last post by:
Hi,
I would like to know what is the best way to move a node within a
tree/treenodecollection (not using Drag/Drop). It can't be done by changing
the index. Found some examples with remove/insert, but is that the only way?
Thanks,
Bart
|
by: Malcolm Dew-Jones |
last post by:
I have a test= that works but I would like to figure out how to move it
into a match=. (Ok, that's unclear but pls keep reading.)
Part of my XSLT file looks like this.
<xsl:template match="@*|node()">
<xsl:choose>
<xsl:when test="
count(.//w:fldSimple/@w:instr)=1
and
|
by: barantamer |
last post by:
hello,
i am actually a php developer and i am new to java
i think i have a pretty easy question.
How can i do this exactly in java ?
foreach ($rootnode->children() as $child)
{
//some code here
}
|
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: 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: 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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
| |