Solved

Datagrid View Contents Format Control and Event Handling

Posted on 2012-04-01
2
272 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

705 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now