Datagridview ScrollBar Looses it's focus after binding reset

FerX32

I have a DataGridView, which I need to update the content every 3 seconds. I am able to save the DGV position with this code:

    private void UpdateBindings()
    {
        int _ScrollPosition = MonitorGridView.FirstDisplayedScrollingRowIndex;

        _BS.ResetBindings(false); // _BS = BindingSource
        if (_ScrollPosition > -1)
        {
            MonitorGridView.FirstDisplayedScrollingRowIndex = _ScrollPosition;
        }
    }

This code works perfect, however, the ONLY problem I am facing is that I lose the FOCUS on my scrollbar after every reset. Let's say I am scrolling to the bottom, and it updates, I need to regrab the scrollbar again. This is very annoying.

My question is exactly same as this one: Scrollbar loses focus when datagridview refreshs its content

However, I am not able to find the answer or figure out a way for me to solve this.

Can anyone please point me to the correct way? Thanks

FerX32

Solved the problem by creating a new vScrollBar and programatically changing the current row value of DataGridView.

    private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
    {
        if (e.NewValue > -1 && e.NewValue < MonitorGridView.Rows.Count)
        {
            MonitorGridView.FirstDisplayedScrollingRowIndex = e.NewValue;
        }
    }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Signature Pad looses focus

From Dev

Hide cursor if window looses focus?

From Dev

Selected item is null when listview looses focus

From Dev

button looses focus when keypad comes up

From Dev

OverlayItem looses focus when FragmentActivity Dismiss

From Dev

OpenGL sprite looses focus on fast move

From Dev

JcomboBox not open on click and looses focus to the one next to it

From Dev

Appcelerator TextField looses focus in TableView on Android 5.0.2

From Dev

macOS NSTextfield looses focus when NSPopover open

From Dev

Scope function only called once, then looses binding

From Dev

Android Data Binding - View Looses Binding When Rotated

From Dev

reusable custom-filter components reset after dropdownlist lost focus

From Dev

Site looses javascript and layout after installing HTTPS

From Dev

VirtualBox looses gtk theme after system update

From Dev

Fire an event only when an focused element looses focus

From Dev

List Box Item gets deselected when its TextBox looses focus

From Dev

Hiding Column In a Datagridview which's data source is a binding source

From Dev

DataGridView not losing focus

From Dev

WPF ListBox: Vertical scrollbar and focus

From Dev

Scrollbar focus on the bottom of the HTML div

From Dev

DatagridView does not show horizontal scrollbar

From Dev

Draw marks on a DataGridView vertical Scrollbar

From Dev

Detect if user is scrolling dataGridView scrollbar

From Dev

DatagridView does not show horizontal scrollbar

From Dev

Reset terminal after interrupting `read -r -s`

From Dev

Reset column increment datagridview

From Dev

Reset column increment datagridview

From Dev

Reset Datagridview SelectionBackColor

From Dev

c# winforms: searching for datagridview event that will fire after changing cell value AND cell focus

Related Related

  1. 1

    Signature Pad looses focus

  2. 2

    Hide cursor if window looses focus?

  3. 3

    Selected item is null when listview looses focus

  4. 4

    button looses focus when keypad comes up

  5. 5

    OverlayItem looses focus when FragmentActivity Dismiss

  6. 6

    OpenGL sprite looses focus on fast move

  7. 7

    JcomboBox not open on click and looses focus to the one next to it

  8. 8

    Appcelerator TextField looses focus in TableView on Android 5.0.2

  9. 9

    macOS NSTextfield looses focus when NSPopover open

  10. 10

    Scope function only called once, then looses binding

  11. 11

    Android Data Binding - View Looses Binding When Rotated

  12. 12

    reusable custom-filter components reset after dropdownlist lost focus

  13. 13

    Site looses javascript and layout after installing HTTPS

  14. 14

    VirtualBox looses gtk theme after system update

  15. 15

    Fire an event only when an focused element looses focus

  16. 16

    List Box Item gets deselected when its TextBox looses focus

  17. 17

    Hiding Column In a Datagridview which's data source is a binding source

  18. 18

    DataGridView not losing focus

  19. 19

    WPF ListBox: Vertical scrollbar and focus

  20. 20

    Scrollbar focus on the bottom of the HTML div

  21. 21

    DatagridView does not show horizontal scrollbar

  22. 22

    Draw marks on a DataGridView vertical Scrollbar

  23. 23

    Detect if user is scrolling dataGridView scrollbar

  24. 24

    DatagridView does not show horizontal scrollbar

  25. 25

    Reset terminal after interrupting `read -r -s`

  26. 26

    Reset column increment datagridview

  27. 27

    Reset column increment datagridview

  28. 28

    Reset Datagridview SelectionBackColor

  29. 29

    c# winforms: searching for datagridview event that will fire after changing cell value AND cell focus

HotTag

Archive