How to use drag-and-drop

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to use drag-and-drop

Rolf-Werner Eilert-2
The basic usage of the drag-and-drop functions isn't quite clear to me.
I couldn't find much information in the wiki about it. Here is my code.
I use t$ as a simple storage place and TextBox1 is only to see what the
thing does.

The user should pick the red cell in GridView1 and drag it to another
cell. The contents should appear there.

I use "MouseUp" and not "Drop" because Drop didn't have any result. But
maybe the way I implemented the whole thing isn't the right one anyhow?

Thank you for your insight!

Rolf


Public t$ As String


Public Sub Form_Open()

   GridView1.Rows.Count = 7
   GridView1.Columns.Count = 5

   TextBox1.Text = t$

End



Public Sub GridView1_Data(Row As Integer, Column As Integer)

   If Row = 4 And Column = 3 Then
     GridView1.Data.Background = Color.Red
     GridView1.Data.Alignment = Align.Center
     GridView1.Data.Text = "E\nKorr\nWg"
     t$ = GridView1.Data.Text

   Endif

End

Public Sub GridView1_Click()

   t$ = GridView1.Current.Text
   TextBox1.Text = ""

End


Public Sub GridView1_MouseDrag()

   TextBox1.Text = t$

End



Public Sub GridView1_MouseUp()

   TextBox1.Text = GridView1.Row & "::" & GridView1.Column

   GridView1.Current.Text = t$

End


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to use drag-and-drop

Charlie
Rolf-Werner Eilert-2 wrote
The basic usage of the drag-and-drop functions isn't quite clear to me.
I couldn't find much information in the wiki about it. Here is my code.
I use t$ as a simple storage place and TextBox1 is only to see what the
thing does.

The user should pick the red cell in GridView1 and drag it to another
cell. The contents should appear there.

I use "MouseUp" and not "Drop" because Drop didn't have any result. But
maybe the way I implemented the whole thing isn't the right one anyhow?
Your code works. Is it that you want to drag the Background colour as well? You can only drag Text or Images so if you want the Background as well you will need to use other tricks. Try your modified code below. If I have missed the point let me know.

t$ As String
iBackGround As Integer

Public Sub Form_Open()

GridView1.Rows.Count = 7
GridView1.Columns.Count = 5
TextBox1.Text = t$

End

Public Sub GridView1_Data(Row As Integer, Column As Integer)

If Row = 4 And Column = 3 Then
  GridView1.Data.Background = Color.Red
  GridView1.Data.Alignment = Align.Center
  GridView1.Data.Text = "E\nKorr\nWg"
  t$ = GridView1.Data.Text
Endif

End

Public Sub GridView1_Click()

t$ = GridView1.Current.Text
TextBox1.Text = ""
iBackGround = GridView1.Current.Background

End

Public Sub GridView1_MouseDrag()

TextBox1.Text = t$

End

Public Sub GridView1_MouseUp()

TextBox1.Text = GridView1.Row & "::" & GridView1.Column
GridView1.Current.Text = t$
GridView1.Current.Background = iBackGround

End

Check out www.gambas.one

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to use drag-and-drop

Rolf-Werner Eilert-2


Am 11.07.2017 um 12:23 schrieb Charlie:

> Rolf-Werner Eilert-2 wrote
>> The basic usage of the drag-and-drop functions isn't quite clear to me.
>> I couldn't find much information in the wiki about it. Here is my code.
>> I use t$ as a simple storage place and TextBox1 is only to see what the
>> thing does.
>>
>> The user should pick the red cell in GridView1 and drag it to another
>> cell. The contents should appear there.
>>
>> I use "MouseUp" and not "Drop" because Drop didn't have any result. But
>> maybe the way I implemented the whole thing isn't the right one anyhow?
> Your code works. Is it that you want to drag the Background colour as well?
> You can only drag Text or Images so if you want the Background as well you
> will need to use other tricks. Try your modified code below. If I have
> missed the point let me know.
>
> Public Sub GridView1_MouseUp()
>
> TextBox1.Text = GridView1.Row & "::" & GridView1.Column
> GridView1.Current.Text = t$
> GridView1.Current.Background = iBackGround
>
> End
>
>

Thank you Charlie for your answer.

I wonder why GridView1_Drop doesn't fire here. So I was forced to use
MouseUp instead. The inconvenience here is that I have to use a flag to
distinguish whether it was a Drag-and-Drop action that fired MouseUp, or
a usual Mouse action that ended there. Otherwise you may get errors when
you click or pull handles or whatever.

So, when GridView1.Drop is True, and I implemented everything correctly,
why is GridView1_Drop not fired?

Regards
Rolf


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Loading...