I have a DataGrid table like this: [img]http://ni8.upanh.com/b1.s24.d1/f869170161faa9e6ad2c272d6f66228e_40513398.capture.png[/img]
How could I change the plain-looking arrows in the RowHeader into row number (Like 1,2,3...)???
Thanks for any help from you guys!

Recommended Answers

All 4 Replies

You can use SQL aliases on your sql query.
e.g :

select Name as '1', City as '2' from Address

Thks, but my problem here is that I can't change DataGrid RowHeader to auto-generated numbers by VB.Net code, not by SQL. Any options?

Private Sub datagridview1_RowPostPaint(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowPostPaintEventArgs) Handles grid1.RowPostPaint
        Dim strRowNumber As String = (e.RowIndex + 1).ToString
        Dim size As SizeF = e.Graphics.MeasureString(strRowNumber, Me.Font)
        If grid1.RowHeadersWidth < CInt((size.Width + 20)) Then
            grid1.RowHeadersWidth = CInt((size.Width + 20))

        End If

        Dim b As Brush = SystemBrushes.ControlText
        e.Graphics.DrawString(strRowNumber, Me.Font, b, e.RowBounds.Location.X + 15, _
                              e.RowBounds.Location.Y + ((e.RowBounds.Height - size.Height) _
                                                       / 2))
    End Sub

Thanks Ezz, I didn't ask for DataGridView but I finished it based on ur idea. Great help! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.