![]() |
Does ReportControl allows cell selection ? |
Post Reply ![]() |
Author | |
supermip ![]() Groupie ![]() Joined: 03 July 2009 Location: Belgium Status: Offline Points: 12 |
![]() ![]() ![]() ![]() ![]() Posted: 15 July 2009 at 6:03am |
Hello All,
Does ReportControl allows cell selection ? It would be like Excel to be able to select a few cells from specific rows. This is in the case we want to export via copy/paste a section of data onto the clipboard. Thank you very much in advanced Best regards. supermip. |
|
![]() |
|
mdoubson ![]() Senior Member ![]() ![]() Joined: 17 November 2008 Status: Offline Points: 1705 |
![]() ![]() ![]() ![]() ![]() |
One cell selection works with flags
wndReport.AllowEdit(TRUE);
wndReport.FocusSubItems(TRUE);
multiple cells - may be in next version (?)
But you can do it on app level - e.g.
app level vars:
Dim aBlock(4) As Integer
Dim hInfo As ReportHitTestInfo actvion function:
Private Sub EmulateBlockSelection()
MsgBox (aBlock(1) & " - " & aBlock(2) & " -- " & aBlock(3) & " - " & aBlock(4)) End Sub store hit info on mouse up event: Private Sub ReportControl1_MouseUp(Button As Integer, Shift As Integer, x As Long, y As Long)
Set hInfo = Me.ReportControl1.HitTest(x, y) aBlock(3) = aBlock(1) aBlock(4) = aBlock(2) aBlock(1) = hInfo.Column.Index aBlock(2) = hInfo.Row.Index End Sub |
|
![]() |
|
supermip ![]() Groupie ![]() Joined: 03 July 2009 Location: Belgium Status: Offline Points: 12 |
![]() ![]() ![]() ![]() ![]() |
Hello Sir,
Thank you for your tip. Is there a way to mark the selected cells in blue only ? Actually, I always have the all rows selected. This would be fine to have the cells selection like in Excel. Thank you very much in advanced. Best regards. supermip. |
|
![]() |
|
mdoubson ![]() Senior Member ![]() ![]() Joined: 17 November 2008 Status: Offline Points: 1705 |
![]() ![]() ![]() ![]() ![]() |
Inside this handler make a loop and change in selected set of cells ForeColor or / and BackColor ,
e.g.
Private Sub BlockSelect_Click()
Dim i, j As Integer 'MsgBox (aBlock(1) & " - " & aBlock(2) & " -- " & aBlock(3) & " - " & aBlock(4)) Me.ReportControl1.SelectedRows.DeleteAll For j = aBlock(2) To aBlock(4) For i = aBlock(1) To aBlock(3) Me.ReportControl1.Rows(j).Record.Item(i).BackColor = RGB(224, 224, 224) Me.ReportControl1.Rows(j).Record.Item(i).ForeColor = RGB(255, 0, 0) Next i Next j Me.ReportControl1.Redraw End Sub ![]() |
|
![]() |
|
mdoubson ![]() Senior Member ![]() ![]() Joined: 17 November 2008 Status: Offline Points: 1705 |
![]() ![]() ![]() ![]() ![]() |
See snapshot and code to produce it
|
|
![]() |
|
RonSanderson ![]() Newbie ![]() Joined: 28 August 2009 Location: United States Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() |
If you do allow copy / paste, what format would you use?
I am looking into a similar application using the Report Control.
The control's built-in Copy and Paste functions are oriented towards placing full rows onto the clipboard and pasting them back in. This is wise because the pasted data always starts at the beginning of the row. This keeps it aligned. Also, they create new rows, so even if the data is wrong, you just end up with a new row, which may not have the same columns - or the same meaning - as the other rows in the grid.
If you have a range of columns offset into the row, do you have some technique for ensuring that the pasted data actually aligns with the current column subset? And how do you plan to paste into the selected rows rather than having the ReportControl create new rows for you?
It seems that you could be pasting data in the wrong cells if the user changes the cell selection range between the cut and the paste.
|
|
![]() |
|
mdoubson ![]() Senior Member ![]() ![]() Joined: 17 November 2008 Status: Offline Points: 1705 |
![]() ![]() ![]() ![]() ![]() |
It suppose to be paste outside of original RC - just selected fragments of data in CSV format?
|
|
![]() |
|
RonSanderson ![]() Newbie ![]() Joined: 28 August 2009 Location: United States Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() |
Yes, the original poster mentioned Excel as a target, and using the Report Control's Copy and Paste gives you a compatible format. These are full rows with \t between each cell and \r\n at the end of each line. This shows up fine in Excel when you do a paste into the Excel grid. However, the poster implies that he wants to copy and paste regions of the grid, and not full rows. I am curious about how he intends to use less than full rows for the copy and paste.
Let's assume that a region of the Report Control is copied. This could be the region shown in your sample image, above.
If it is formatted like a full row, with the same \t and \r\n delimiter, it wouls obey the same rules as the RC's current Copy function. You can paste the region's data into Excel. You can cut the data, or part of it, from Excel, and then paste it back into the Report Control at the same position or another position.
If you copy some data to Excel, change it, then copy all of it from Excel, and paste it back to the exact same place in the Report Control, you should be fine. But if you copy more or fewer rows or columns from Excel, or move the selection target in the Report Control, the data may not get pasted where it should be.
So I was wondering how the poster was going to match up his rows and columns.
I was hoping he would share some insight about his plans to make sure the rows and columns he was pasting in made sense to his application. If they were misaligned he could be pasting garbage over his original data.
|
|
![]() |
|
mdoubson ![]() Senior Member ![]() ![]() Joined: 17 November 2008 Status: Offline Points: 1705 |
![]() ![]() ![]() ![]() ![]() |
You can use smth like ,,,a,,b,,\n to keep original size and position of a and b cells (I use CSV case - "," as \t in your post)
|
|
![]() |
|
RonSanderson ![]() Newbie ![]() Joined: 28 August 2009 Location: United States Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() |
That's not a bad idea. It adds some context information - the null delimiters - to what would be expected in the clipboard.
My idea was to also add information to the clipboard to help maintain the context.
I would add an extra row before all the selected rows. It contains an identifier for each column.
I then add an extra item before each row's data. It uniquely identifies the row.
On a paste, I can unambiguously determine where the data goes. It does not matter what the user has selected in the Report Control. The data goes exactly where it needs to go.
In both approaches, the user has to paste the right data back in.
Anyway, even though I have an approach I like, I was wondering if the original poster had to wrestle with these problems. He seems to be one of the first to try to use a columnar selection format. |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |