Home All Groups Group Topic Archive Search About

Images in a Windows DataGrid

Author
7 Jul 2006 8:41 AM
teddysnips
WINDOWS APPLICATION

I have to port a Web application to a Windows application.

I've no experience of Windows apps in .NET, though I've been doing Web
apps in ASP.NET since it came out.

I have a normal System.Windows.Forms.DataGrid.  I wish to display an
image in each cell alongside some text - the image would be conditional
upon the value in the cell.

How can I do this in a Windows app?  In the Web app I put it in the
Grid_ItemDataBound event:

[...]

With e.Item.Cells.Item(cell)
   .Font.Bold = True
   err = GetRuleFailureDescription(startArbStatus, endArbStatus,
durationArbStatus, _
                IIf(hours Is DBNull.Value, 0.0, hours), ruleID)

   .Text = "<IMG" & _
   " title=" & Chr(34) & err & Chr(34) & _
   " id=" & Chr(34) & ID & "Mon" & Chr(34) & _
   " runat=" & Chr(34) & "server" & Chr(34) & _
   " height=" & Chr(34) & "16" & Chr(34) & _
   " width=" & Chr(34) & "16" & Chr(34) & _
   " src=" & Chr(34) & "../../images/incident16.gif" & Chr(34) & _
   " align=" & Chr(34) & "left" & Chr(34) & _
   " onclick=" & Chr(34) &
"javascript:document.getElementById('txtArb').value = 'true'" & Chr(34)
& _
   ">" & .Text
End With

Thanks for any help anyone can offer.

Edward

Author
7 Jul 2006 2:53 PM
Brian Tkatch
teddysn***@hotmail.com wrote:
Show quoteHide quote
> WINDOWS APPLICATION
>
> I have to port a Web application to a Windows application.
>
> I've no experience of Windows apps in .NET, though I've been doing Web
> apps in ASP.NET since it came out.
>
> I have a normal System.Windows.Forms.DataGrid.  I wish to display an
> image in each cell alongside some text - the image would be conditional
> upon the value in the cell.
>
> How can I do this in a Windows app?  In the Web app I put it in the
> Grid_ItemDataBound event:
>
> [...]
>
> With e.Item.Cells.Item(cell)
>    .Font.Bold = True
>    err = GetRuleFailureDescription(startArbStatus, endArbStatus,
> durationArbStatus, _
>                 IIf(hours Is DBNull.Value, 0.0, hours), ruleID)
>
>    .Text = "<IMG" & _
>    " title=" & Chr(34) & err & Chr(34) & _
>    " id=" & Chr(34) & ID & "Mon" & Chr(34) & _
>    " runat=" & Chr(34) & "server" & Chr(34) & _
>    " height=" & Chr(34) & "16" & Chr(34) & _
>    " width=" & Chr(34) & "16" & Chr(34) & _
>    " src=" & Chr(34) & "../../images/incident16.gif" & Chr(34) & _
>    " align=" & Chr(34) & "left" & Chr(34) & _
>    " onclick=" & Chr(34) &
> "javascript:document.getElementById('txtArb').value = 'true'" & Chr(34)
> & _
>    ">" & .Text
> End With
>
> Thanks for any help anyone can offer.
>
> Edward

I am not sure of this, but perhaps you can research it.

In a Windows DataGrid you can have TableStyles, which have
DataGridColumnStyles. DatGridColumnStyle itself cannot be instanitated,
but it's derivative types can. The two easily availible are
DataGridTextColumn and DataGridBoolColumn. Perhaps there is one
availible for images?

I just starting messing with TableStyles so i'm not too familiar with
it yet.
B.