下面的代碼將使用CSS來將具有交替行顏色的表格寫入html文件。在寫入磁盤之後,當用例如直接查看html文件時Firefox,Chrome,IE等,交替的行顏色是可見的。但是,在VS2015中,將HTML文件加載到WebBrowser1控件後,交替行顏色不可見。VS 2015 - WebBrowser控件不會在CSS中顯示交替的表格行顏色
我已經檢查過其他地方和其他地方的其他帖子,很明顯WebBrowser只是包裝IE瀏覽器,並解決WebBrowser的問題有解決方法涉及安裝第三方開源。但是,從MS處理這個問題的直接解決方案呢?這對於MS和VS2015來說似乎是一個不完善的問題,因爲它意味着與VS2015捆綁在一起的當前控件在CSS方面存在問題。任何基於MS的解決方案?
Dim sw As New StreamWriter(filename)
sw.WriteLine("<!DOCTYPE html><html><body>")
sw.WriteLine("<style type=" & """" & "text/css" & """" & ">")
sw.WriteLine("table.gridtable {")
sw.WriteLine(" font-family: verdana,arial,sans-serif;")
sw.WriteLine(" font-size:12px;")
sw.WriteLine(" color: #333333;")
sw.WriteLine(" border-width: 1px;")
sw.WriteLine(" border-color: #666666;")
sw.WriteLine(" border-collapse: collapse;")
sw.WriteLine("}")
sw.WriteLine("table.gridtable th {")
sw.WriteLine(" border-width: 1px;")
sw.WriteLine(" padding: 8px;")
sw.WriteLine(" border-style: solid;")
sw.WriteLine(" border-color: #666666;")
sw.WriteLine(" background-color: #dedede;")
sw.WriteLine("}")
sw.WriteLine("table.gridtable tr {")
sw.WriteLine("background-color: #ffffff;")
sw.WriteLine("}")
sw.WriteLine("table.gridtable tr:nth-child(even) {")
sw.WriteLine("background-color: #fdf5e6;")
sw.WriteLine("}")
sw.WriteLine("table.gridtable td {")
sw.WriteLine(" border-width: 1px;")
sw.WriteLine(" padding: 8px;")
sw.WriteLine(" border-style: solid;")
sw.WriteLine(" border-color: #666666;")
sw.WriteLine("}")
sw.WriteLine("</style>")
sw.WriteLine("<table class=" & """" & "gridtable" & """" & " Align=center>")
sw.WriteLine("<tr>")
sw.Write("<th>" & "Output" & "</th>")
sw.Write("<th>" & "Output" & "</th>")
sw.Write("<th>" & "Output" & "</th>")
sw.Write("<th>" & "Output" & "</th>")
sw.WriteLine("</tr>")
sw.WriteLine("<tr>")
sw.WriteLine("<td align=""center""><font color=" & """" & "#000000" & """" & ">Hello</font></td>")
sw.WriteLine("<td align=""center""><font color=" & """" & "#000000" & """" & ">Hello</font></td>")
sw.WriteLine("<td align=""center""><font color=" & """" & "#000000" & """" & ">Hello</font></td>")
sw.WriteLine("<td align=""center""><font color=" & """" & "#000000" & """" & ">Hello</font></td>")
sw.WriteLine("</tr>")
sw.WriteLine("<tr>")
sw.WriteLine("<td align=""center""><font color=" & """" & "#000000" & """" & ">Hello</font></td>")
sw.WriteLine("<td align=""center""><font color=" & """" & "#000000" & """" & ">Hello</font></td>")
sw.WriteLine("<td align=""center""><font color=" & """" & "#000000" & """" & ">Hello</font></td>")
sw.WriteLine("<td align=""center""><font color=" & """" & "#000000" & """" & ">Hello</font></td>")
sw.WriteLine("</tr>")
sw.WriteLine("<tr>")
sw.WriteLine("<td align=""center""><font color=" & """" & "#000000" & """" & ">Hello</font></td>")
sw.WriteLine("<td align=""center""><font color=" & """" & "#000000" & """" & ">Hello</font></td>")
sw.WriteLine("<td align=""center""><font color=" & """" & "#000000" & """" & ">Hello</font></td>")
sw.WriteLine("<td align=""center""><font color=" & """" & "#000000" & """" & ">Hello</font></td>")
sw.WriteLine("</tr>")
sw.WriteLine("<tr>")
sw.WriteLine("<td align=""center""><font color=" & """" & "#000000" & """" & ">Hello</font></td>")
sw.WriteLine("<td align=""center""><font color=" & """" & "#000000" & """" & ">Hello</font></td>")
sw.WriteLine("<td align=""center""><font color=" & """" & "#000000" & """" & ">Hello</font></td>")
sw.WriteLine("<td align=""center""><font color=" & """" & "#000000" & """" & ">Hello</font></td>")
sw.WriteLine("</tr>")
sw.WriteLine("</table>")
sw.WriteLine("</body></html>")
sw.dispose
檢查此頁http://stackoverflow.com/questions/3822537/wpf-webbrowser-control-what-browser-does-it-use –
和https://social.msdn.microsoft.com/Forums/ vstudio/EN-US/6abee729-ac0b-47c5-9603-d1b3050618af /網頁瀏覽器 - 不適用 - CSS-正確?論壇= WPF –