简体   繁体   中英

how to position column names vertically in datagridview in vb.net

I appologise in advance if my question may appear silly to you but I have a problem with positioning column names in a dataGridview vertically. I'm populating DataGridView using flowing code:

Dim StrQwery As String = "SELECT  * FROM employees WHERE employee_id = (select MAX(employee_id) FROM employees AND registered = 'UNREGISTERED';

        Dim smd As MySqlCommand
        smd = New MySqlCommand(StrQwery, myconn)
        smd.CommandType = CommandType.Text

        Dim da As New MySqlDataAdapter(smd)
        Dim cb As New MySqlCommandBuilder(da)
        Dim ds As New DataSet()
        da.Fill(ds)

        GridView1.DataSource = ds.Tables(0)

        If n = 1 Then
            If Not Page.IsPostBack Then
                GridView1.DataBind()
            End If
        Else
            GridView1.DataBind()
        End If

everything works perfectly except that I need to position account attributes like name, position, ID number etc not horizontally but vertically. Something like this:

|NAME | John |

|SURNAME | Philips|

|POSITION| Manager|

and I can't find a way how to do it. Can anyone give me a hint in my problem please?

many thanks in advance.

If you want to present a detailed view of DB record, GridView is not the best choice (which is more suitable for tabular display of multiple records).

For your case take a look at DetailsView control

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM