Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Report Control
  New Posts New Posts RSS Feed - Does ReportControl allows cell selection ?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Does ReportControl allows cell selection ?

 Post Reply Post Reply
Author
Message
supermip View Drop Down
Groupie
Groupie


Joined: 03 July 2009
Location: Belgium
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote supermip Quote  Post ReplyReply Direct Link To This Post Topic: Does ReportControl allows cell selection ?
    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.


Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 20 July 2009 at 3:23pm
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
Back to Top
supermip View Drop Down
Groupie
Groupie


Joined: 03 July 2009
Location: Belgium
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote supermip Quote  Post ReplyReply Direct Link To This Post Posted: 22 July 2009 at 4:58am
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.
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 23 July 2009 at 12:42pm
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
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 24 July 2009 at 9:58pm
See snapshot and code to produce it
Back to Top
RonSanderson View Drop Down
Newbie
Newbie


Joined: 28 August 2009
Location: United States
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote RonSanderson Quote  Post ReplyReply Direct Link To This Post Posted: 28 August 2009 at 10:17am
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.
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 28 August 2009 at 10:48am
It suppose to be paste outside of original RC - just selected fragments of data in CSV format?
Back to Top
RonSanderson View Drop Down
Newbie
Newbie


Joined: 28 August 2009
Location: United States
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote RonSanderson Quote  Post ReplyReply Direct Link To This Post Posted: 28 August 2009 at 10:58am

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.
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 28 August 2009 at 11:13am
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)
Back to Top
RonSanderson View Drop Down
Newbie
Newbie


Joined: 28 August 2009
Location: United States
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote RonSanderson Quote  Post ReplyReply Direct Link To This Post Posted: 28 August 2009 at 11:45am
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.
  • If they cut cells and the clipboard contains ,,,a,,b,,\n, then paste in Excel and make changes, they need to copy all the empty cells back again so the clipboard still contains ,,,x,,y,,\n
  • If you have row and column headers, these show up as data in Excel, and the user has to make sure to copy those back with any data changes. Then the clipboard has all the information needed to synchronize back to the data in the Report Control. Obviously a custom Paste() routine has to be written since this heading data is not meant to appear in the grid. An advantage here is the user can rearrange the rows and columns, or omit some, since the headers define exactly where the data goes.

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.

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.109 seconds.