Images in a Windows DataGrid

  • Thread starter Thread starter teddysnips
  • Start date Start date
T

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
 
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.
 
Back
Top