ReoGrid Forum

Fast and powerful .NET Spreadsheet Component

You are not logged in.

Announcement

This forum no longer accepts new user registrations, please report your question, problem and feedback to the issue page of ReoGrid on Github. Thanks for your cooperation.

https://github.com/unvell/ReoGrid/issues

#1 2015-08-27 11:24:20

asparatu
Member
Registered: 2014-08-20
Posts: 196

Range Style Question

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..

6dd7b9fc587de105af8d97f27b216d9c.png

    '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

#2 2015-08-28 17:01:29

Jing
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: Range Style Question

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 Jing (2015-08-28 17:01:55)

Offline

#3 2015-08-29 07:48:48

asparatu
Member
Registered: 2014-08-20
Posts: 196

Re: Range Style Question

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.. smile

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

#4 2015-08-29 08:29:22

asparatu
Member
Registered: 2014-08-20
Posts: 196

Re: Range Style Question

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..

79d042594311340583e7717dbfb33332.png

Shane

Offline

#5 2015-09-04 11:35:29

Jing
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: Range Style Question

Hi Shane could you post some code that describes how to set the borders? I couldn't confirm this problem.

Offline

#6 2015-09-05 12:21:27

asparatu
Member
Registered: 2014-08-20
Posts: 196

Re: Range Style Question

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

#7 2015-09-06 02:34:43

Jing
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: Range Style Question

I used your code, changed colors and style, with frozen cells. The result looks as expected.

282.png

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

#8 2015-09-07 08:22:34

asparatu
Member
Registered: 2014-08-20
Posts: 196

Re: Range Style Question

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

#9 2015-09-07 10:30:42

Jing
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: Range Style Question

OK, you mean this white line.
283.png

Let me check this problem.

Offline

#10 2015-09-07 15:56:26

Jing
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: Range Style Question

Shane you could use BackColor property of control to avoid the white line:

grid.BackColor = Color.DimGray

Offline

#11 2015-09-08 03:05:25

asparatu
Member
Registered: 2014-08-20
Posts: 196

Re: Range Style Question

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

Board footer

Powered by FluxBB