Serial Number In Datagridview Vb Net Concatenate

How to add Serial number in Data GridView using C#. (How to display large number of rows in a DataGridView?). How to give serial number in gridview using c#. How to show the row index in row header in datagridview? VB.Net clear datagridview rows without the headers. Move Index to last row in Datagridview.

Active2 years, 6 months ago

May be this question is not much important for you but I am facing problem in this. I have a DataGridView in which I add rows by.....

and the rows display like...

Now I want to clear Row (Sl No. - 2) but I want to maintain the serial numbers like below.

or I want to clear Row (Sl No. - 1) and want to maintain the serial numbers like

It means I want to delete/clear a row from DataGridView maintaining the serial numbers.

I tried like....

But failed to get the output.

How could I do this ?

Thanks in advance

RajSerial Number In Datagridview Vb Net ConcatenateRaj
3751 gold badge7 silver badges29 bronze badges

3 Answers

I have found my answer. Sorry for the post.

While searching in DataGridView events, I found an event RowPrePaint and just three lines of code of this event solved the problem.

Thanks for viewing my post and also sorry for wasting your valuable time by missing the event.

RajRaj
3751 gold badge7 silver badges29 bronze badges

DataGridView.RowPrePaint event will be raised every time when datagridview must be repainting.
This will happened for example when you drag over datagridview another form or MessageBox
or when you minimize/hide form and reopen it again...

In your case you need update Serial No only after count of the rows was changed.

Method Dgv_RowCountChanged will be executed in the event handlers of RowsAdded and RowsRemoved

FabioFabio
21.7k2 gold badges21 silver badges50 bronze badges

Here is how to create a Column index autogenerate serial number of each row:

Vb 2010 datagridview example

Then on the codebehing:

Donald Duck

Vb Concatenate Strings

4,30813 gold badges42 silver badges66 bronze badges
Tushar JoshiTushar Joshi

Not the answer you're looking for? Browse other questions tagged vb.netserializationdatagridview or ask your own question.

24 Mar 2010CPOL
May occasions we need to give Serial numbers to our grid like 1,2,3,4,5, this I have tried my hand for a while and what I found.....I have posted it in someones questions earlier. We can give alphabets also but its usage is limited so that part is omitted. (it is somewhat tedious...
Datagridview

May occasions we need to give Serial numbers to our grid like 1,2,3,4,5, this I have tried my hand for a while and what I found.....


I have posted it in someones questions earlier. We can give alphabets also but its usage is limited so that part is omitted. (it is somewhat tedious also).


Vb Net Datagridview Add Row

This code works as same when we apply paging.


We cannot use this on BoundFields because they support only those objects who have Databinding event

Using Datagridview Vb