See Also Example
Determines the contents of the cells in a grid's selected region. Not available at design time.
[form.]grid.Clip[ = stringexpression ]
The stringexpression can contain the contents of multiple rows and columns. In stringexpression, a tab character (ANSI character 9) indicates a new cell in a row, and a carriage return (ANSI character 13) indicates the beginning of a new row. Use the Chr function to embed these characters in strings. For example, this line of code puts text into a selected area two rows high and two columns wide:
Grid1.Clip = "1st" & Chr(9) & "a" & Chr(13) & "2nd" & Chr(9) & "b"
When placing data into a grid, only the selected cells are affected. If there are more cells in the selected region than are described in stringexpression, the remaining cells are set to null. If there are more cells described in stringexpression than in the selected region, the unused portion of stringexpression is ignored.
SelEndCol, SelStartCol, SelEndRow, SelStartRow Properties
Chapter 3, "Creating and Using Controls"
Clip Property Example
The example puts the current date and time into the selected area of the grid when the user clicks the form. To try this example, use the Add File command on the File menu to add GRID.VBX to a project, paste the code into the Declarations section of a new form, and then draw a grid. Press F5 to run the program.
Sub Form_Load ()
Grid1.Rows = 8 ' Set rows and columns.
Grid1.Cols = 5
Sub Form_Click ()
Dim Msg As String
Msg = "Date" & Chr(9) ' Create a text string.
Msg = Msg & Format(Now, "Short Date") & Chr(13)
Msg = Msg & "Time" & Chr(9)
Msg = Msg & Format(Now, "Short Time")
Grid1.Clip = Msg ' Paste string into grid.