473,473 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Windows Forms, Data Grid, and Link Buttons

Hello,

I have a Windows form with a datagrid control, and would like one column to
appear as a hyperlink, so when clicking on it, it will open IE and go to the
web. Unfortunately, I cannot find an example. My code is below.
Essentially what I am trying to do is get a list of patches installed on a
system (via WMI), and display them in a datagrid, with the last column being
a link. The RemoveChars function simply removes alphabetic characters from
the KB article to complete the formation of the link. I have tried using
System.LinkButton and System.RichTextBox as they seem to have some link
abilities to no avail, as it errors saying the data type cannot be null.
Any help or ideas would be greatly appreciated!

Paul

DataTable table = new DataTable("Updates");

DataColumn IDColumn = new DataColumn("Hot Fix
ID",System.Type.GetType("System.String"));
DataColumn DescriptionColumn = new
DataColumn("Description",System.Type.GetType("Syst em.String"));
DataColumn FixCommentsColumn = new DataColumn("Service Pack In
Effect",System.Type.GetType("System.String"));

DataColumn LinkColumn=new
DataColumn("Link",System.Type.GetType("System.Stri ng"));

table.Columns.Add(IDColumn);

table.Columns.Add(DescriptionColumn);

table.Columns.Add(FixCommentsColumn);

table.Columns.Add(LinkColumn);

foreach(ManagementObject oReturn in oReturnCollection)

{

DataRow row = table.NewRow();

row["Hot Fix ID"]=oReturn["HotFixID"].ToString();

row["Description"]=oReturn["Description"].ToString();

row["Service Pack In Effect"]=oReturn["ServicePackInEffect"].ToString();

row["Link"]="http://support.microsoft.com/default.aspx?scid=kb;en-us;"+Remov
eChars(oReturn["HotFixID"].ToString());

table.Rows.Add(row);

}

dgKB.DataSource=table;

DataGridTableStyle ts = new DataGridTableStyle();

ts.MappingName = "Updates";

dgKB.TableStyles.Clear();

dgKB.TableStyles.Add(ts);


Nov 16 '05 #1
1 2667
Hello Paul,

You will need to create a custom DataGridColumnStyle-derived class. As far
as I remember, there's a good example of a custom column style right in the
MSDN's topic on the DataGridColumnStyle class.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Paul Yanzick" <ya******@hotmail.com> wrote in message
news:NI********************@giganews.com...
Hello,

I have a Windows form with a datagrid control, and would like one column
to
appear as a hyperlink, so when clicking on it, it will open IE and go to
the
web. Unfortunately, I cannot find an example. My code is below.
Essentially what I am trying to do is get a list of patches installed on a
system (via WMI), and display them in a datagrid, with the last column
being
a link. The RemoveChars function simply removes alphabetic characters
from
the KB article to complete the formation of the link. I have tried using
System.LinkButton and System.RichTextBox as they seem to have some link
abilities to no avail, as it errors saying the data type cannot be null.
Any help or ideas would be greatly appreciated!

Paul

DataTable table = new DataTable("Updates");

DataColumn IDColumn = new DataColumn("Hot Fix
ID",System.Type.GetType("System.String"));
DataColumn DescriptionColumn = new
DataColumn("Description",System.Type.GetType("Syst em.String"));
DataColumn FixCommentsColumn = new DataColumn("Service Pack In
Effect",System.Type.GetType("System.String"));

DataColumn LinkColumn=new
DataColumn("Link",System.Type.GetType("System.Stri ng"));

table.Columns.Add(IDColumn);

table.Columns.Add(DescriptionColumn);

table.Columns.Add(FixCommentsColumn);

table.Columns.Add(LinkColumn);

foreach(ManagementObject oReturn in oReturnCollection)

{

DataRow row = table.NewRow();

row["Hot Fix ID"]=oReturn["HotFixID"].ToString();

row["Description"]=oReturn["Description"].ToString();

row["Service Pack In Effect"]=oReturn["ServicePackInEffect"].ToString();

row["Link"]="http://support.microsoft.com/default.aspx?scid=kb;en-us;"+Remov
eChars(oReturn["HotFixID"].ToString());

table.Rows.Add(row);

}

dgKB.DataSource=table;

DataGridTableStyle ts = new DataGridTableStyle();

ts.MappingName = "Updates";

dgKB.TableStyles.Clear();

dgKB.TableStyles.Add(ts);


Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Olli Krollmann | last post by:
hello folks, we have been developing several .NET-based windows forms applications during the last two years. there are two mysterious display problems that we have encountered so far but have...
2
by: Greg Bacchus | last post by:
Hi, I'm getting an exception that really has me stumped. It's sporadic at best, it's only happened a handful of times. This particular time it happened when the user pressed 'Alt-S' to save the...
1
by: krian | last post by:
Hi, I need a help from anybody. My problem is here I wrote two WebApplication in ASP.net Using C#. The name of the applications are (Journal.aspx and Payment.aspx). These Two pages have DataGrids...
2
by: pmud | last post by:
Hi, I am exporting data from an EDITABLE DATA GRID EXCEL. But the 1st column in data grid is Edit Column. I want to display all columns in Excel except for the Edit column. The following...
6
by: Alan Silver | last post by:
Hello, I have a page that displays a data list with info from a database. The grid has the usual stuff, edit, update, delete etc. Below this I have a section where they can add a new entry to...
6
by: Fred Morrison | last post by:
1. No Columns collection. 2. No ability to easily synchronize the underlying DataTable of a DataGrid when a row is deleted in the Grid. Once you sort (via the column headers) all bets are off as...
1
by: Jabco | last post by:
I need a grid that displays hierachical related tables. The grid's DataSource is a dataset. Maybe there is a better way I don't know. There are 2 tables in the dataset. They have a Relations on...
3
by: John Jasobs | last post by:
I know this has been asked before but I have not seen it answered. How would one implement nested datagrids in windows forms based on the table relationships within a dataset? Or, is there some...
22
by: Jordan S. | last post by:
SQL Server will be used as the back-end database to a non trivial client application. In question is the choice of client application: I need to be able to speak intelligently about when one...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.