[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 227
  • Last Modified:

How to drag text box data and drop into an msflexgrid

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
JackVannoy
Asked:
JackVannoy
  • 4
  • 4
1 Solution
 
Jacques Bourgeois (James Burger)PresidentCommented:
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
 
JackVannoyAuthor Commented:
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
 
Jacques Bourgeois (James Burger)PresidentCommented:
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
JackVannoyAuthor Commented:
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
 
Jacques Bourgeois (James Burger)PresidentCommented:
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
 
JackVannoyAuthor Commented:
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
 
Jacques Bourgeois (James Burger)PresidentCommented:
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
 
JackVannoyAuthor Commented:
Did not actually get the help I needed.  Maybe I ask too Much.  Will close the question anyway
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now