Foros del Web » Programación para mayores de 30 ;) » .NET »

mARCAR UNA ROW EN UN DATAGRIDVIEW COMO SI FUERA ERROR

Estas en el tema de mARCAR UNA ROW EN UN DATAGRIDVIEW COMO SI FUERA ERROR en el foro de .NET en Foros del Web. Salu2. Estoy haciendo un programa de bitácoras y tengo ciertos datos en la base de datos, Al cargar los datos de un datagridwiev, tengo unos ...
  #1 (permalink)  
Antiguo 19/06/2009, 22:25
 
Fecha de Ingreso: julio-2006
Ubicación: En algún lugar de un grán pais
Mensajes: 112
Antigüedad: 17 años, 9 meses
Puntos: 2
mARCAR UNA ROW EN UN DATAGRIDVIEW COMO SI FUERA ERROR

Salu2.
Estoy haciendo un programa de bitácoras y tengo ciertos datos en la base de datos, Al cargar los datos de un datagridwiev, tengo unos datos en una columna que de acuerdo a cierto valor, representan algo, Por ejemplo 1 = transferido, 2 = en espera, 3 = error.

Quisiera que cuando un registro traiga el numero 3, entonces marcar un error en ese registro, como si hubiera un error en una actualización, sin embargo no es error, sino que yo lo quiero pintar como error.

Existe alguna forma de hacer esto?...
De antemano les agradezco su ayuda.

Gracias.
  #2 (permalink)  
Antiguo 20/06/2009, 00:15
Avatar de Dradi7  
Fecha de Ingreso: junio-2008
Ubicación: Peru - Lima
Mensajes: 1.518
Antigüedad: 15 años, 10 meses
Puntos: 220
Respuesta: mARCAR UNA ROW EN UN DATAGRIDVIEW COMO SI FUERA ERROR

bueno si quieres pintar toda la fila de la grilla utiliza el defaultcellstyle

Ejm:

Pintar las filas de la grilla que en la columna 2 tenga como valor 1

Código C#:
Ver original
  1. foreach DataGridViewRow Row in DgvPrueba.Rows
  2. {
  3.     if(Row.cells[1].value == 1)
  4.     {
  5.            Row. DefaultCellStyle.ForeColor = Color.Red; // Con esto el texto de la fila cambia a rojo
  6.      }
  7. }
__________________
La clave de todo triunfador es eliminar todas sus excusas y sus limitaciones
  #3 (permalink)  
Antiguo 20/06/2009, 01:06
 
Fecha de Ingreso: julio-2006
Ubicación: En algún lugar de un grán pais
Mensajes: 112
Antigüedad: 17 años, 9 meses
Puntos: 2
Respuesta: mARCAR UNA ROW EN UN DATAGRIDVIEW COMO SI FUERA ERROR

Hola!!!.
Muchas gracias, me sirve bastante esto.
Además me gustaría poder hacer algo como esto mira:

ojala me pudieras ayudar, graciasa!!!!

(no me deja poner la imagen, te la pongo en partecitas)
visita triple w en subirimagenes punto com
/otros-pantalla-2754058 punto html
  #4 (permalink)  
Antiguo 20/06/2009, 09:33
 
Fecha de Ingreso: enero-2007
Ubicación: Tingo María - Perú
Mensajes: 399
Antigüedad: 17 años, 3 meses
Puntos: 13
Respuesta: mARCAR UNA ROW EN UN DATAGRIDVIEW COMO SI FUERA ERROR

Me.DataGridView1.Row(0).ErrorText = "Error..."
__________________
Vivir para ser buenos y ser buenos para servir mejor.
  #5 (permalink)  
Antiguo 22/06/2009, 13:07
 
Fecha de Ingreso: julio-2006
Ubicación: En algún lugar de un grán pais
Mensajes: 112
Antigüedad: 17 años, 9 meses
Puntos: 2
Respuesta: mARCAR UNA ROW EN UN DATAGRIDVIEW COMO SI FUERA ERROR

hola!!!.
No, marca lo siguiente:

System.ArgumentOutOfRangeException was unhandled by user code
Message="El índice estaba fuera del intervalo. Debe ser un valor no negativo e inferior al tamaño de la colección.
Nombre del parámetro: index"
ParamName="index"
Source="mscorlib"
StackTrace:
en System.Collections.ArrayList.get_Item(Int32 index)
en System.Windows.Forms.DataGridViewColumnCollection. get_Item(Int32 index)
en EnvioDeMailTransferencias.frmEnviaMail.DataGridVie w1_CellFormatting(Object sender, DataGridViewCellFormattingEventArgs e) en C:\Documents and Settings\mijuarez\Mis documentos\Visual Studio 2005\Projects\WindowsApplication3\WindowsApplicati on3\Form1.vb:línea 121
en System.Windows.Forms.DataGridView.OnCellFormatting (DataGridViewCellFormattingEventArgs e)
en System.Windows.Forms.DataGridView.OnCellFormatting (Int32 columnIndex, Int32 rowIndex, Object val, Type formattedValueType, DataGridViewCellStyle cellStyle)
en System.Windows.Forms.DataGridViewCell.GetFormatted Value(Object value, Int32 rowIndex, DataGridViewCellStyle& cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
en System.Windows.Forms.DataGridViewRowHeaderCell.Get ErrorIconBounds(Graphics graphics, DataGridViewCellStyle cellStyle, Int32 rowIndex)
en System.Windows.Forms.DataGridViewCell.PaintErrorIc on(Graphics graphics, DataGridViewCellStyle cellStyle, Int32 rowIndex, Rectangle cellBounds, Rectangle cellValueBounds, String errorText)
en System.Windows.Forms.DataGridViewRowHeaderCell.Pai ntPrivate(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates dataGridViewElementState, Object formattedValue, String errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts, Boolean computeContentBounds, Boolean computeErrorIconBounds, Boolean paint)
en System.Windows.Forms.DataGridViewRowHeaderCell.Pai nt(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates cellState, Object value, Object formattedValue, String errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
en System.Windows.Forms.DataGridViewCell.PaintWork(Gr aphics graphics, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates cellState, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
en System.Windows.Forms.DataGridViewRow.PaintHeader(G raphics graphics, Rectangle clipBounds, Rectangle rowBounds, Int32 rowIndex, DataGridViewElementStates rowState, Boolean isFirstDisplayedRow, Boolean isLastVisibleRow, DataGridViewPaintParts paintParts)
en System.Windows.Forms.DataGridViewRow.Paint(Graphic s graphics, Rectangle clipBounds, Rectangle rowBounds, Int32 rowIndex, DataGridViewElementStates rowState, Boolean isFirstDisplayedRow, Boolean isLastVisibleRow)
en System.Windows.Forms.DataGridView.PaintRows(Graphi cs g, Rectangle boundingRect, Rectangle clipRect, Boolean singleHorizontalBorderAdded)
en System.Windows.Forms.DataGridView.PaintGrid(Graphi cs g, Rectangle gridBounds, Rectangle clipRect, Boolean singleVerticalBorderAdded, Boolean singleHorizontalBorderAdded)
en System.Windows.Forms.DataGridView.OnPaint(PaintEve ntArgs e)
  #6 (permalink)  
Antiguo 22/06/2009, 13:21
 
Fecha de Ingreso: enero-2007
Ubicación: Tingo María - Perú
Mensajes: 399
Antigüedad: 17 años, 3 meses
Puntos: 13
Respuesta: mARCAR UNA ROW EN UN DATAGRIDVIEW COMO SI FUERA ERROR

Cita:
Iniciado por miguelajh Ver Mensaje
El índice estaba fuera del intervalo. Debe ser un valor no negativo e inferior al tamaño de la colección.
Tienes que asegurate de que la fila exista
__________________
Vivir para ser buenos y ser buenos para servir mejor.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:38.