简体   繁体   中英

Vb.net DataGridView Hyperlink Column

I'm trying to retrieve records from MS Access database, one of the field is Hyperlink type in MS Access, when the records display in Vb.net datagridview, the hyperlink field is not showing as hyperlink, instead it showing just normal text, how should I convert/declare the hyperlink column in datagridview?

I know I can declare the columntype if the column if I add the column in datagridview, but now I'm retrieving whole branch of records from MS Access, so do not have any column pre-created in DGV.

 Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=D:\\e\\CTMSDBClient2007.accdb" Dim MyConn As OleDbConnection Dim da As OleDbDataAdapter Dim ds As DataSet Dim tables As DataTableCollection Dim source1 As New BindingSource MyConn = New OleDbConnection MyConn.ConnectionString = connString ds = New DataSet tables = ds.Tables da = New OleDbDataAdapter("SELECT * FROM Query5Search", MyConn) 'Change items to your database name da.Fill(ds, "Query5Search") 'Change items to your database name Dim view As New DataView(tables(0)) source1.DataSource = view DataGridView1.DataSource = view 

A hyperlink column will never be created for you automatically. You always have to create it yourself, either in the designer or in code. You can choose whichever you find more convenient but, either way, you have to set the DataPropertyName of the column so that it knows which column/property of the data source to bind to. When you then set the DataSource of the grid, no text box column will be created for that data source column, which is the default for text data.

For an example of how to add a column manually in the designer, you might like to check this out . The example uses a combo box column but the principle is the same regardless of the column type. Hyperlinks are easier than combo boxes because you don't have to populate the drop-down list.

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