473,395 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Datagridview ROWHEADER position after refresh Grid

I am facing this problems in my project!

I have a DATAGRIGVIEW1 which is refreshing in every 10 sec. to update records.

After refreshing the ROWHEADER (Left Black pointer or record Indicator) move to first Record, but my ROW is selected, only ROWHEADER goes up which create a problem by clicking NEXT button.

I am NEW here don't know to allow to paste code or not!

Expand|Select|Wrap|Line Numbers
  1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  2.  
  3. '' SCROLLING POSITION BEFORE REFRESH
  4. MaintainScrollPosition.GetSBarPos(DataGridView1)
  5.  
  6. DataGridView1.DataSource = Get_records()
  7.  
  8. '' SCROLLING POSITION AFTER REFRESH
  9. MaintainScrollPosition.SetSBarPos(DataGridView1)
  10.  
  11. '' SELECTED RECORD POSITION
  12. DataGridView1.Rows(iTopRow).Selected = True
  13.  
  14. Call gridcolor()
  15. End Sub
  16.  
  17. '' DATA REFRESH FUNCTION
  18. Public Function Get_records() As Data.DataTable
  19.  
  20. Dim col As Integer = DataGridView1.CurrentCell.Selected
  21. Dim row As Integer = DataGridView1.CurrentRow.Selected
  22.  
  23. Try
  24.  
  25. Dim sSQL As String = "Select ddd from ddd"
  26. Dim myDA As New MySqlDataAdapter(sSQL, conn)
  27. Dim dsData As New DataSet()
  28.  
  29. myDA.Fill(dsData, "tblcurrentrundown")
  30. Return dsData.Tables("tblcurrentrundown")
  31.  
  32. 'NOT WORKING---set the grid back the the first cell displayed
  33. DataGridView1.FirstDisplayedCell = DataGridView1.Item(col, row)
  34.  
  35. conn.Close()
  36. Catch ex As Exception
  37. conn.Close()
  38. Throw
  39. Finally
  40. conn.Close()
  41.  
  42. End Try
  43.  
  44. End Function
  45.  
  46.  
  47.  
Attached Images
File Type: jpg 02-Datagridview1-After-Refr.jpg (119.9 KB, 103 views)
File Type: jpg 01-Datagridview1-Before-Ref.jpg (116.5 KB, 102 views)
Nov 20 '12 #1
0 1777

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: dimitri pater | last post by:
Hello, To be honest, I also posted this on the wxPython mailing list. But I thought maybe some of you on the python list can help me... I am trying to refresh a pane of a notebook that contains...
5
by: Peter | last post by:
How do I get DataGridViewCell cell position in a window? For a button I would do this: this.Button.PointToClient(this.Button.Location) But what do I do for DataGridViewCell? Thanks
0
by: romancoelho | last post by:
Hey everyone, I know this has to be simple, but can't figure out how to do it. How can I display the grid lines in all rows in the gird. The default behavior of the DataGridView seems to be that it...
0
by: Dagan | last post by:
Hello I have 2 threads, one for adding\removing rows to\from DataTable that is bind to DataGridView and the main thread that views the DataGridView, when I change any row in the DataTable the...
5
by: Brett Romero | last post by:
I have a simple test app with one form, one datagridview, and a contextmenustrip. I've assigned the menustrip to the datagridview and given the grid one column. There isn't any data in the grid. ...
1
by: bern11 | last post by:
I'm trying to bind a DataGridView to a BindingList that is a member of the main form. It worked once, then stopped. Now it does not display data when the list is clearly populated. I just get an...
1
by: Arved Sandstrom | last post by:
This seems to be something so simple that none of the hundred-odd tutorials and forum threads that I have looked at (:-)) apparently thinks it's a problem. In a nutshell, I have two...
2
by: priyamtheone | last post by:
How can I get the position of a certain cell of a datagridview. To be specific I don't want the mouse coordinates. Suppose I have a datagridview with Name (ReadOnly), ID and TransDate columns and I...
2
by: yahooguy | last post by:
I have an application where a datagridview is used to display some data, a datatable is bounded to it, and i want to put some text in the front of some rows to indicate that they are different from...
3
by: AnagJohari | last post by:
I want to insert the record at any position in a grid view means means if i add Insert buuton at every row of grid view. & when i click on insert button of an perticular row a new row is created...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.