Developers can define interactions between users and rows and columns, for example, you can change the size of a row or column, move a row or column, freeze a specified row or column, and search for data in a row or column.
Change the size of a row or column
You can allow users to re-adjust the size of the row or column in the form. Set the row's Resizable attribute to allow users to reset the row size. Set the column's Resizable attribute to allow users to reset the column size. You can also double-click the separation line between the beginning of a column and the beginning of the column to reset the width of the column to adapt to the width of the first text of the column.
To reset the size of a row or column, you only need to left-click the line at the beginning of the row or the beginning of the column and drag it to the desired position to release the mouse. As shown in, a toolbar is displayed when the left button is pressed. Be sure to click the right edge of the column or the bottom edge of the row to change the column width or Row Height. Double-click the separation line between rows to automatically adjust the height of the row to display the highest text in the row. Double-click the separation line between columns to automatically adjust the width of the column to display the widest text in the column.
650) this. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "title =" clip_image002 "border =" 0 "alt =" clip_image002 "width =" 419 "height =" 193 "src =" http://www.bkjia.com/uploads/allimg/131228/1TK54F5-0.jpg "/>
By default, you can modify the size of rows or columns in the data area. However, the size of the first row and the first column cannot be modified. In code, you can reset the size of the beginning or end of a row, not limited to rows or columns in the data area. You can also use the Resizable attribute to overwrite the default behavior to prevent users from changing the size.
The following code allows a column at the beginning of a row to change the size:
- fpSread.Sheets[0].RowHeader.Columns[0].Resizable = true;
The following code allows all columns in the beginning of a row to change the size:
- fpSread.Sheets[0].RowHeader.Columns.Default.Resizable = true;
You can use the method in the SheetView class to determine the size of rows or columns that can be modified by the user:
GetColumnSizeable
SetColumnSizeable
GetRowSizeable
SetRowSizeable
Move rows or columns
You can drag and drop rows or columns. Set the AllowRowMove attribute to allow users to move rows, and set the AllowColumnMove attribute to allow users to move columns. To allow users to move multiple rows or columns, set the AllowRowMoveMultiple or AllowColumnMoveMultiple attribute.
To move a row or column, you only need to left-click the row or column header and drag it forward or backward in the first column of the row. If you drag multiple rows or columns, select the rows or columns you want to operate on ). The moved rows or columns follow the mouse pointer to display a transparent copy. As shown in, the fourth column is moved to the left.
650) this. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "title =" clip_image004 "border =" 0 "alt =" clip_image004 "width =" 491 "height =" 323 "src =" http://www.bkjia.com/uploads/allimg/131228/1TK5N13-1.jpg "/>
You can use the SheetView. MoveRow method to program and relocate a row. You can also use SheetView. RemoveRows to remove multiple rows at a time. You can use the SheetView. MoveColumn method to program and relocate a column. You can also use the SheetView. RemoveColumns method to remove multiple columns at a time.
By removing a column area, you can Remove several columns at a time. For example:
- fpSpread1.Sheets(0).Columns(1,5).Remove()
Set a fixed frozen row or column.
You can freeze rows or columns in a form to make them non-scroll ). You can freeze the rows at the top of any form to make it a leading row. You can also freeze any multiple columns on the left, to make it a leading column, you can also freeze the rows at the bottom of any multiple forms or the rightmost column. No matter how you scroll the mouse, the frozen leading or leading columns are displayed at the top or leftmost of the view. No matter how you scroll the mouse, the frozen ending or ending columns are displayed at the bottom or rightmost of the view.
The following chart shows the position of a frozen tail column and tail row in the view.
650) this. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "title =" clip_image006 "border =" 0 "alt =" clip_image006 "width =" 545 "height =" 222 "src =" http://www.bkjia.com/uploads/allimg/131228/1TK5KS-2.jpg "/>
Attributes of frozen rows and columns include:
FrozenRowCount
FrozenColumnCount
FrozenTrailingColumnCount
FrozenTrailingRowCount
Frozen rows or columns cannot be rolled at run time, but they can be rolled at design time.
The tail and Tail Frozen columns are not repeatedly printed at the bottom and right of each page, and are printed as the last or last row. The leading and leading columns can be repeatedly printed.
Set the FrozenRowCount, FrozenColumnCount, FrozenTrailingColumnCount, or FrozenTrailingRowCount attributes of the form:
- fpSpread1.Sheets[0].FrozenColumnCount = 2;
-
- fpSpread1.Sheets[0].FrozenRowCount = 2;
-
- fpSpread1.Sheets[0].FrozenTrailingColumnCount = 2;
-
- fpSpread1.Sheets[0].FrozenTrailingRowCount = 2;
Search for rows or columns containing data
When using a form, you can use different members in the Form class to find the last or formatted index of a trip or column. You can use the following method provided by the form.
GetLastNonEmptyColumn Method
GetLastNonEmptyRow Method
You can use the following attributes to obtain the number of rows or columns containing data:
NonEmptyColumnCount attribute
NonEmptyColumnCount attribute
Adjust the row and column size to fit the data size
You can adjust the column width or Row Height Based on the length and width of the data in the cell. The size of the row or column where the maximum data is located is the preferred size. The preferred dimensions are as follows:
GetPreferredHeight method in Row class
GetPreferredWidth method in Column Class
GetPreferredRowHeight method in the SheetView class
GetPreferredColumnWidth method in the SheetView class
GetPreferredCellSize method in the SheetView class
The GetPreferredHeight method in the Row class and the GetPreferredWidth method in the Column class always include the header cells. For form classes that overload the GetPreferredColumnWidth method, when the overload allows you to select cells that contain or do not contain titles, there will always be a cell that contains titles. In the following code, width1 and wid2include the title cell, while width3 does not include the title cell.
- float width1 = fpSpread.Sheets[0].Columns[0].GetPreferredWidth();
-
- float width2 = fpSpread.Sheets[0].GetPreferredColumnWidth(0);
-
- float width3 = fpSpread.Sheets[0].GetPreferredColumnWidth(0, true);
You can use multiple methods to set the column width and Row Height:
- FarPoint.Win.Spread.Row row;
-
- FarPoint.Win.Spread.Column col;
-
- float sizerow;
-
- float sizercol;
-
- row = fpSpread1.ActiveSheet.Rows[0];
-
- col = fpSpread1.ActiveSheet.Columns[0];
-
- fpSpread1.ActiveSheet.Cells[0, 0].Text = "This text is used to determine the height and width.";
-
- sizerow = row.GetPreferredHeight();
-
- sizecol = col.GetPreferredWidth();
-
- row.Height = sizerow;
-
- col.Width = sizecol;
|
This article from the "grape city control blog" blog, please be sure to keep this source http://powertoolsteam.blog.51cto.com/2369428/629857