esquima Posted October 18, 2007 at 09:39 PM Report Share #141276 Posted October 18, 2007 at 09:39 PM Boas eu carrego uma datagrid com dados da minha bd...agora queira por todas as linhas a vermelho que tivessem o estado = Fechado Link to comment Share on other sites More sharing options...
Asgorath Posted October 19, 2007 at 08:26 AM Report Share #141315 Posted October 19, 2007 at 08:26 AM Boas . Datagrid ou DatagridView? "The Dark Side Clouds Everthing. Impossible To See The Future Is."My rig: Intel Core 2 Quad Q9450 | abit IP35P | 4G Kingston 800 Mhz | XFX GeForce 9800 GX2 1G ddr3 | 2X WD5000AAJS 500Gb Sata 2 | PSU 600W || Caixa El-Diablo | Creative XMod Link to comment Share on other sites More sharing options...
Weasel Posted October 19, 2007 at 09:10 AM Report Share #141317 Posted October 19, 2007 at 09:10 AM Faz assim No while em que preenches a Datagrid, ou coisa similar mete assim: If (DataGridView1.Item("estado", i).Value.ToString() = "Fechado") Then DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.Red End If Nota: eu usei a var i como contador do index da linha actual. Knowledge to the masses Link to comment Share on other sites More sharing options...
esquima Posted October 19, 2007 at 12:28 PM Author Report Share #141360 Posted October 19, 2007 at 12:28 PM Uma datagrid... ja agora qual e a diferença de uma datagrid e uma datagrid view Link to comment Share on other sites More sharing options...
Asgorath Posted October 19, 2007 at 01:01 PM Report Share #141376 Posted October 19, 2007 at 01:01 PM A datagridview é tem mais funcionalidades que a datagrid. http://www.syncfusion.com/FAQ/winforms/FAQ_c44c.aspx#q745q ve faq 5.14 How do I color a individual cell depending upon its value or some external method? "The Dark Side Clouds Everthing. Impossible To See The Future Is."My rig: Intel Core 2 Quad Q9450 | abit IP35P | 4G Kingston 800 Mhz | XFX GeForce 9800 GX2 1G ddr3 | 2X WD5000AAJS 500Gb Sata 2 | PSU 600W || Caixa El-Diablo | Creative XMod Link to comment Share on other sites More sharing options...
esquima Posted October 19, 2007 at 01:04 PM Author Report Share #141381 Posted October 19, 2007 at 01:04 PM Poisss.. e que eu tou a usar o vb.2003 e n tem o datagridview pois so ha no 2005...vou ter mesmo de trabalhar com datagrid Link to comment Share on other sites More sharing options...
esquima Posted October 19, 2007 at 01:59 PM Author Report Share #141399 Posted October 19, 2007 at 01:59 PM ja tou farto de pesquisar e n encontro nada para vb.2003, para o que quero fazer Link to comment Share on other sites More sharing options...
Asgorath Posted October 19, 2007 at 02:12 PM Report Share #141402 Posted October 19, 2007 at 02:12 PM Public Class DataGridColoredTextBoxColumn Inherits DataGridTextBoxColumn Public Sub New() End Sub Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal source As CurrencyManager, ByVal rowNum As Integer, ByVal backBrush As Brush, ByVal foreBrush As Brush, ByVal alignToRight As Boolean) ' the idea is to conditionally set the foreBrush and/or backbrush ' depending upon some crireria on the cell value ' Here, we color anything that begins with a letter higher than 'F' Try Dim o As Object o = Me.GetColumnValueAtRow(source, rowNum) If (Not (o) Is Nothing) Then Dim c As Char c = CType(o, String).Substring(0, 1) If (c > "F") Then ' could be as simple as ' backBrush = new SolidBrush(Color.Pink); ' or something fancier... backBrush = New LinearGradientBrush(bounds, Color.FromArgb(255, 200, 200), Color.FromArgb(128, 20, 20), LinearGradientMode.BackwardDiagonal) foreBrush = New SolidBrush(Color.White) End If End If Catch ex As Exception ' empty catch Finally ' make sure the base class gets called to do the drawing with ' the possibly changed brushes MyBase.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight) End Try End Sub End Class "The Dark Side Clouds Everthing. Impossible To See The Future Is."My rig: Intel Core 2 Quad Q9450 | abit IP35P | 4G Kingston 800 Mhz | XFX GeForce 9800 GX2 1G ddr3 | 2X WD5000AAJS 500Gb Sata 2 | PSU 600W || Caixa El-Diablo | Creative XMod Link to comment Share on other sites More sharing options...
Weasel Posted October 19, 2007 at 03:32 PM Report Share #141416 Posted October 19, 2007 at 03:32 PM Não tinha reparado que era DataGrid e não DataGridView... Vb.net 2003 realmente é bem mais complicado de fazer isso UPGRADE para VB.NET 2005!!!! Knowledge to the masses Link to comment Share on other sites More sharing options...
esquima Posted October 19, 2007 at 06:12 PM Author Report Share #141457 Posted October 19, 2007 at 06:12 PM Poisss..ja vi que e bem mais dificil...vou passar para 2005 depois deste projecto..agora n vem convem fazer o upgrade...entrentanto continuo entalado com isto 🙂 Link to comment Share on other sites More sharing options...
Gooden Posted October 20, 2007 at 09:47 AM Report Share #141550 Posted October 20, 2007 at 09:47 AM porque é que em vez de usares uma datagrid não usas uma listview? pelo menos e um concelho que te dou que fica muito melhor esteticamente 🙂 Link to comment Share on other sites More sharing options...
esquima Posted October 22, 2007 at 03:46 AM Author Report Share #142032 Posted October 22, 2007 at 03:46 AM Pessoal...mudei para o vb.2005..bem mais facil trabalhar com as datagridview...ja consegui me orientar a colorir as linhas conforme o meu estado=fechado....se no futuro alguem precisar apitem 🙂 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now