You are not logged in.
This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.
Hello Jing,
I have am having an issue with setting rangestyle. When the sheet is created i have 3 or 4 columns and what i want to do is have default style for the whole sheet then one column have different style. The column is the 3 column i want to apply this to. When i have 4 column the style for the 3rd column get applied to the 4th column. What I was trying to avoid is taking make if statement to check the column count..
Also, Want say, i like your screen capture program you made. Now, i have been using for all the screen captures, i been post here..
Shane
Here is image..
'Workbook setting
With rgDataGatheringGrid
'Removes the Scrollbars and Worksheet Tab Control
.SetSettings(WorkbookSettings.View_ShowScrolls Or WorkbookSettings.View_ShowSheetTabControl, False)
'Sets the control width size
If cboBetterIf.SelectedIndex = 2 Then
.Width = 296
Else
.Width = 196
End If
'Sets the control height size
.Height = 441
End With
'Worksheet setting
With rgDataGatheringSheet
'Reset the worksheet
.Reset()
'Sets the selection Mode
.SelectionMode = WorksheetSelectionMode.Cell
'Sets the number of rows
.SetRows((ProjectInfoData.B + ProjectInfoData.C) + 1)
'Sets column count
If cboBetterIf.SelectedIndex = 2 Then .SetCols(4) Else .SetCols(3)
'Sets the validrange values
Dim posOne As New ReoGridPos(1, CInt(IIf(.ColumnCount = 4, .ColumnCount - 2, .ColumnCount - 1)))
Dim posTwo As New ReoGridPos(.RowCount - 1, CInt(IIf(.ColumnCount = 4, .ColumnCount - 2, .ColumnCount - 1)))
'Sets the validrange
validRange = New ReoGridRange(String.Format("{0}:{1}", posOne.ToAddress, posTwo.ToAddress))
'Sets the selection range of the validrange
.SelectionRange = New ReoGridRange(validRange.StartPos)
'Removes the RowHeader and Column Header
.SetSettings(WorksheetSettings.View_ShowRowHeader Or WorksheetSettings.View_ShowColumnHeader, False)
'Freezes the Header Row
.FreezeToCell(1, 1, FreezePosition.Top)
'Sets the Row Header Size
.RowHeaders(0).Height = 40
'Sets Default column header sizes.
.ColumnHeaders(0).Width = 55
.ColumnHeaders(1).Width = 65
.ColumnHeaders(2).Width = 75
'Sets Default row headers text names
.SetCellData("A1", "Run No.")
.SetCellData("B1", "Reference")
.SetCellData("C1", "Reading")
'Sets the DFT Column
If cboBetterIf.SelectedIndex = 2 Then
'Sets the column header size.
.ColumnHeaders(3).Width = 100
'Sets the row headers text
.SetCellData("D1", "Distance from Target")
End If
'Border Styles
.SetRangeBorders(New ReoGridRange(0, 0, .RowCount, .ColumnCount), BorderPositions.All, _
New RangeBorderStyle() With {.Color = BorderColor,
.Style = BorderLineStyle.Solid})
'Sets the Background Styles
.SetRangeStyles(New ReoGridRange(1, 0, (.RowCount - 1), .ColumnCount),
New WorksheetRangeStyle() With {.Flag = PlainStyleFlag.BackColor Or PlainStyleFlag.TextColor,
.BackColor = MainBackColor,
.TextColor = MainForeColor})
'Sets Text Alignment
.SetRangeStyles(New ReoGridRange(0, 0, .RowCount, .ColumnCount),
New WorksheetRangeStyle() With {.Flag = PlainStyleFlag.AlignAll,
.HAlign = ReoGridHorAlign.Center,
.VAlign = ReoGridVerAlign.Middle})
'Sets the Header Row Styles
.SetRangeStyles(New ReoGridRange(0, 0, 1, .ColumnCount),
New WorksheetRangeStyle() With {.Flag = PlainStyleFlag.BackColor Or PlainStyleFlag.TextColor Or PlainStyleFlag.FontStyleBold _
Or PlainStyleFlag.TextWrap,
.BackColor = MainBackColor,
.TextColor = MainForeColor,
.Bold = True,
.TextWrapMode = TextWrapMode.WordBreak})
'Sets the Data Background Styles
.SetRangeStyles(New ReoGridRange(1, 2, (.RowCount - 1), 3),
New WorksheetRangeStyle() With {.Flag = PlainStyleFlag.BackColor Or PlainStyleFlag.TextColor,
.BackColor = DataBackColor,
.TextColor = DataForeColor})
'sets run number
For i As Integer = 1 To .RowCount - 1
.SetCellData(i, 0, i)
.Cells(i, 0).IsReadOnly = True
Next
End With
Last edited by asparatu (2015-08-29 05:14:24)
Offline
Hi Shane,
Thanks! If you have any suggestions to the screen capture tool just let me know.
For your question:
Step 1: Set a default style for entire worksheet
VB.NET:
With grid.CurrentWorksheet
.SetRangeStyles(ReoGridRange.EntireRange, New WorksheetRangeStyle() With { _
[i]style object settings here[/i]
})
End With
Step 2: Set style for single column
VB.NET:
With grid.CurrentWorksheet.ColumnHeaders(0).Style
.TextColor = Color.Green
End With
Replace the grid variable with your control name.
Regards, Jing
Last edited by Jingwood (2015-08-28 17:01:55)
Offline
Hello Jing,
If I have suggestion for your screen capture program i will tell you.. One thing i did notice and this might be bug.. when version 1.2.0.0 starts it has bubble message box shows and tell you that there is new version 1.4.0.0 that you can download and if click on the bubble message box it does not do anything and just closes the message box.
As for the rangestyes.. thank you.. I just realized something.. When you set style the way it works is like CSS and the last style is applied to cell or range of cells, because of me just noticing that.. i will program the style different now.. also.. thanks for show to use reogridrange.entirerange did not know that existed..
Shane
Here is the code end up with..
'Sets the default workbook styles
.SetRangeStyles(ReoGridRange.EntireRange,
New WorksheetRangeStyle() With {.Flag = PlainStyleFlag.AlignAll Or PlainStyleFlag.BackColor _
Or PlainStyleFlag.TextColor Or PlainStyleFlag.TextWrap, _
.BackColor = MainBackColor,
.TextColor = MainForeColor,
.HAlign = ReoGridHorAlign.Center,
.VAlign = ReoGridVerAlign.Middle,
.TextWrapMode = TextWrapMode.WordBreak})
'sets the default workbook border styles.
.SetRangeBorders(ReoGridRange.EntireRange, BorderPositions.All,
New RangeBorderStyle() With {.Color = BorderColor,
.Style = BorderLineStyle.Solid})
'Sets the Data column setting..
.ColumnHeaders(2).Style.BackColor = DataBackColor
.ColumnHeaders(2).Style.TextColor = DataForeColor
'Sets the header for data column
.SetRangeStyles(New ReoGridRange("C1"), New WorksheetRangeStyle() With {.Flag = PlainStyleFlag.BackColor Or PlainStyleFlag.TextColor,
.BackColor = MainBackColor,
.TextColor = MainForeColor})
'Sets the row header 0 to bold
.RowHeaders(0).Style.Bold = True
Offline
Hello Jing,
Something did notice when i was add the border on the grid was that there is solid border on the top and left side of the grid but when does the bottom and right side it does the dash border and not solid. Would that not be solid all the way around on the outside and dashed in the cell borders? I really notice this when i was background was white..
Shane
Offline
Hi Shane could you post some code that describes how to set the borders? I couldn't confirm this problem.
Offline
Hello Jing,
My code in post 3 is the code i use to make that border.. I just changed it to yellow and dash line.
Shane
Offline
I used your code, changed colors and style, with frozen cells. The result looks as expected.
Code:
With grid.CurrentWorksheet
'Sets the default workbook styles
.SetRangeStyles(ReoGridRange.EntireRange,
New WorksheetRangeStyle() With {.Flag = PlainStyleFlag.AlignAll Or PlainStyleFlag.BackColor _
Or PlainStyleFlag.TextColor Or PlainStyleFlag.TextWrap, _
.BackColor = Color.Turquoise,
.TextColor = Color.Teal,
.HAlign = ReoGridHorAlign.Center,
.VAlign = ReoGridVerAlign.Middle,
.TextWrapMode = TextWrapMode.WordBreak})
'sets the default workbook border styles.
.SetRangeBorders(ReoGridRange.EntireRange, BorderPositions.All,
New RangeBorderStyle() With {.Color = Color.Tomato,
.Style = BorderLineStyle.Dashed})
'Sets the Data column setting..
.ColumnHeaders(2).Style.BackColor = Color.YellowGreen
.ColumnHeaders(2).Style.TextColor = Color.YellowGreen
'Sets the header for data column
.SetRangeStyles(New ReoGridRange("C1"), New WorksheetRangeStyle() With {.Flag = PlainStyleFlag.BackColor Or PlainStyleFlag.TextColor,
.BackColor = Color.Red,
.TextColor = Color.Teal})
'Sets the row header 0 to bold
.RowHeaders(0).Style.Bold = True
.FreezeToCell(3, 0)
End With
Offline
Hello Jing,
What i am talking about is the white area on the right side of the grid. The control board is not all the around the control, it only shows on top and left side of the control. Looking at my first post and look at the other post that has the yellow board dashed boarder, there is no solid control boarder. You can see it on the top and left side of the control also.. the board inside the control is fine.
There is no control solid board on the bottom and right side of the control.
Shane
Last edited by asparatu (2015-09-07 08:23:38)
Offline
OK, you mean this white line.
Let me check this problem.
Offline
Shane you could use BackColor property of control to avoid the white line:
grid.BackColor = Color.DimGray
Offline
Hello Jing,
Yes.. i mean that.. should there not be board around the whole outside of the control? I have the background the same color of the tabpage.. I just had white when i creating it and had not changed it.. that is when i notice that board does not go all the way around the control.. and i seen it on top and left of the control only
Shane
Offline