Solved

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

Posted on 2008-06-17
1
1,574 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
1 Comment
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 500 total points
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deletiā€¦
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now