Solved

UltraWinGrid VB.NET - How to loop thru the grid adding a counter to row

Posted on 2008-06-17
1
1,670 Views
Last Modified: 2013-11-15
I have a unbound column in my grid that I would like to use as a row counter (1,2,3, etc).  This row should repopulte each time the dataset is refreshed or rows are changed (deleted, added).
I've tried a couple of ways and have ended up unsuccessful in my attempts.

Any help would be great!

Thanks
gridrow.jpg
0
Comment
Question by:wayneburr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 500 total points
ID: 21805688
The following code will update a column (with a column key of "Counter") with the row index associated with the datarow.  Everytime you delete a row, you'll need to refresh the counter column again.
Private Sub UltraGrid1_InitializeRow(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) Handles UltraGrid1.InitializeRow
	e.Row.Cells("Counter").Value = e.Row.ListIndex + 1
End Sub
 
Private Sub UltraGrid1_AfterRowsDeleted(ByVal sender As Object, ByVal e As System.EventArgs) Handles UltraGrid1.AfterRowsDeleted
	For Each row As Infragistics.Win.UltraWinGrid.UltraGridRow In UltraGrid1.Rows
		row.Cells("Counter").Value = row.ListIndex + 1
	Next
End Sub

Open in new window

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question