Solved

Datagrid View Contents Format Control and Event Handling

Posted on 2012-04-01
2
274 Views
Last Modified: 2012-04-02
Hi

I have the following VB.NET code to populate a gridview (in a windows application form):

        Dim NotfData As New DataSet
        NotfData = MC.DB(NoftDataSQL()) 'this will populate "NotfData.Tables(0)" with Data

        Notf_Grid.Columns.Add("NotfCount", "No.")
        Notf_Grid.Columns.Add("NotfLink", "Notification Link")
        Notf_Grid.Columns.Add("NotfID", "Notification ID")

        For i = 0 To NotfData.Tables(0).Rows.Count - 1
            Notf_Grid.Rows.Add((i + 1).ToString, NotfData.Tables(0).Rows(i).Item("Notf. Link"), NotfData.Tables(0).Rows(i).Item("Notf. ID"))
        Next

        Notf_Grid.Columns(0).AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells
        Notf_Grid.Columns(1).AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells
        Notf_Grid.Columns(2).Visible = False

Open in new window


I have three questions:

Question 1: How can I make Notf_Grid.Columns(1) formats its rows values into Hyperlinks instead of pure text?

Question 2: How can I add an (OnClick) event handler for each row/cell of this [Notf_Grid]?

Question 3: How can I format the text (bold, italic, underline ... etc.) of any cell in this [Notf_Grid]
0
Comment
Question by:alfardan
2 Comments
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 500 total points
ID: 37794899
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37795286
1) Check the AddLinkColumn method in below example
    http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcomboboxcolumn%28VS.90%29.aspx#Y700

2) Handle the CellClick and SelectionChanged events

3) Use the CellFormatting event
    http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.cellformatting.aspx
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

786 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