Solved

How to drag text box data and drop into an msflexgrid

Posted on 2014-10-16
8
187 Views
Last Modified: 2014-10-22
In vb6 we have a procedure that will drag data from a text box and drop it into an msflexgrid.  How can I do this in vb.net
0
Comment
Question by:JackVannoy
  • 4
  • 4
8 Comments
 
LVL 40
ID: 40385859
The way to perform drag and drop operations in .NET is explained at http://msdn.microsoft.com/en-us/library/aa984430(v=vs.71).aspx

The msflexgrid is a complex control that uses an old technology. Unless you do very simple things, it causes a lot of problems in .NET. You might work a lot and end up having to scrap everything.

I would suggest that you use a .NET grid instead.
0
 

Author Comment

by:JackVannoy
ID: 40389254
Hi JamesBuger,

Thank you for your response.  I accessed the article that you had referred to, and have no problem dragging from one text box to another.  I also now have a grid that emulates the .Net grid and it does have a (Allow Drag Drop) property.  The problem with the referenced article is that it does not show code for dropping from a text box to a grid.  Can  you be of any further help to me by showing me the code or referencing another article that shows the code?

Thanks,

Jack
0
 
LVL 40
ID: 40389917
The problem is probably that you are using a COM grid. msflexgrid is not a .NET grid, it is a COM grid, that was used in VB6. I do not think that you can easily do Drag and Drop between them. I do not have VB6 anymore on my system, so I cannot test.

That is  why I suggested that you use a .NET grid instead.

A grid that emulates the .NET grid might not have all the features. You might look for the documentation for your specific grid.

You should ideallly use the DataGridView that comes by default with newer versions of .NET.

If you really need to show the one to many relations as the msflexgrid did, you can try with the DataGrid control. It does not show in the Toolbox by default, because it was replaced by the DataGridView a few versions ago. But you can activate it by right clicking on the Toolbox and selecting Choose Items. Be sure to select the DataGrid for Windows Forms, because there is also one for the Web that won't work in a Windows application.
0
 

Author Comment

by:JackVannoy
ID: 40395594
Hi JamesBuger,

So far, I have not been able to make the Drag Drop from a Text Box to a specific DataGrid row and column work for me.  I am very new in VB.Net.  I would need actual code examples for the specific events for both the Text Box and the DataGrid.  If this is asking more than I should, I apologize.  Just let me know and I will close this question.

Thanks,

Jack
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 40
ID: 40395726
Show me the code you have up to know, I will try to see what does not work. I need the code both from the receiving end (the DragDrop event) and from the start if the information comes from one of your own controls (DoDragDrop method). If the data comes from an external application, I need to know what type of data you are moving (text, file, image...).
0
 

Author Comment

by:JackVannoy
ID: 40397277
I will show the code being used in vb6.  Hope this is what you need

 'NOTE: The TasksDrag_txt object is setting over column 0 of the Tasks_grd(1)

Private Sub Tasks_grd_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim I As Integer
    Select Case Index
        Case 0:                                 'Personal tasks
       
        Case 1:                                 'Available tasks
            If Button = 1 And Tasks_grd(1).Col = 0 And EditTasks_btn.Enabled = False Then
                I = Tasks_grd(1).Row
                '=== Begin the drag procedure =================================
                TaskDrag_txt.Visible = True
                TaskDrag_txt.Text = Tasks_grd(1).TextMatrix(I, 0)
                TaskDrag_txt.Drag vbBeginDrag
                '==============================================================
            End If
    End Select
End Sub


Private Sub Tasks_grd_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)

    Dim I As Integer
    Dim J As Integer
    Dim Inserted As Boolean
   
    I = Tasks_grd(1).Row
    Select Case Index
        Case 0:                             'Personal tasks
            Inserted = False
            J = Int(Y / RH) + (Tasks_grd(Index).TopRow) - 1
            If J = Tasks_grd(Index).Rows - 1 Then
                Tasks_grd(0).AddItem _
                    Source & vbTab & _
                    Tasks_grd(1).TextMatrix(I, 1) & vbTab & _
                    Tasks_grd(1).TextMatrix(I, 2)
            Else
                Inserted = True
                Tasks_grd(0).AddItem _
                    Source & vbTab & _
                    Tasks_grd(1).TextMatrix(I, 1) & vbTab & _
                    Tasks_grd(1).TextMatrix(I, 2), J
            End If
            TaskDrag_txt.Visible = False
            If Tasks_grd(0).TextMatrix(1, 0) = "" Then
                Tasks_grd(0).RemoveItem 1
            End If
        Case 1:                             'Available tasks
            TaskDrag_txt.Visible = False
    End Select
End Sub
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 40398146
No. I do not have time to convert code. I can look  at your .Net code to see what you do not do right however.

And forget VB6 (also called VB classic). Moving to .Net, you keep the same syntax, but you enter a world where almost everything is very different. You have to learn new ways of working.
0
 

Author Closing Comment

by:JackVannoy
ID: 40398195
Did not actually get the help I needed.  Maybe I ask too Much.  Will close the question anyway
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now