ReoGrid Forum

Fast and powerful .NET Spreadsheet Component

You are not logged in.

Announcement

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.

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

#1 2016-03-18 02:02:40

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

Grid Resizing Issue

Hello Jing,
    When i resize form and change the size of the grid in sizechanged event of the form it works fine if you are not at bottom of the grid. what happens is there lot of blank space on the bottom of the last cell to end of the grid. If you select one of the cell and move up the grid refreshes and look fine. I tried to do sheet.posfocus, it works but does not go to the top of the grid keeps the same way. I have tried to invalidate both the grid and sheet and does not change it.

Shane

 Private Sub frmBvsC_SizeChanged(sender As Object, e As EventArgs) Handles Me.SizeChanged
        If Application.OpenForms.OfType(Of Form).Contains(Me) Then
            'Sets the control height size
            If Me.WindowState = FormWindowState.Maximized Then
                '768 Pixels height = 581
                rgDataGatheringGrid.Height = 581
                rgResultsGrid.Height = 581
            Else
                '600 pixels height = 441
                rgDataGatheringGrid.Height = 441
                rgResultsGrid.Height = 441
            End If

            rgDataGatheringSheet.RequestInvalidate()
            rgResultsSheet.RequestInvalidate()

            rgDataGatheringSheet.FocusPos = New CellPosition(validRange.StartPos.ToAddress)
            rgResultsSheet.FocusPos = New CellPosition(validRange2.StartPos.ToAddress)
        End If
    End Sub

This code in the grids

   'Sets the control height size
            If Me.WindowState = FormWindowState.Maximized Then
                '768 Pixels
                .Height = 581
            Else
                '600 pixels
                .Height = 441
            End If

Last edited by asparatu (2016-03-18 14:20:09)

Offline

#2 2016-03-19 00:43:31

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

Re: Grid Resizing Issue

If you want keep worksheet aligned to bottom when your form is resized. You can manually scroll the worksheet to the end. Code like this:

C#:

class MyForm : Form
{
  private System.Drawing.Size lastSize;

  protected override void OnResize(EventArgs e)
  {
	base.OnResize(e);

	var diff = this.Size - lastSize;

	if (diff != this.Size)
	{
		grid.ScrollCurrentWorksheet(-diff.Width, -diff.Height);
	}

	this.lastSize = this.Size;
  }
}

VB.NET:

Public Class Form4
	Private lastSize As Size

	Protected Overrides Sub OnLoad(e As EventArgs)
		MyBase.OnLoad(e)

		grid.ShowScrollEndSpacing = False
	End Sub

	Protected Overrides Sub OnResize(e As EventArgs)
		MyBase.OnResize(e)

		Dim diff = Me.Size - Me.lastSize

		If (diff <> Me.Size) Then
			grid.ScrollCurrentWorksheet(-diff.Width, -diff.Height)
		End If

		Me.lastSize = Me.Size
	End Sub
End Class

Last edited by Jingwood (2016-03-19 00:45:38)

Offline

#3 2016-03-19 03:10:40

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

Re: Grid Resizing Issue

Hello Jing,
   Thank you, I will add that to the code.. I see i need to start using the overrides of the events and not use the events handlers to the controls.

Shane

Last edited by asparatu (2016-03-19 03:10:59)

Offline

#4 2016-03-22 01:32:06

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

Re: Grid Resizing Issue

Hello Jing,
  This worked good thank you.. I just adjust the code a little so it would not show halfway in between the cell but other then that it worked good. smile
Shane

Offline

Board footer

Powered by FluxBB