?
Solved

How to drag text box data and drop into an msflexgrid

Posted on 2014-10-16
8
Medium Priority
?
213 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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
 
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 1500 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
This video teaches viewers about errors in exception handling.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

801 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