I am developing an application where I use the RadGridView to display information from various stores. I use a GridView and show only the information of one store at a time.
In CellFormating'm formatting the text of GridView and am placing an image in the GridView cells when it has a note or comment.
The problem with it is that sometimes CellFormatting puts the image of the note in cells where it is not and does not remove the image of the note when changing store. The data in the GridView if the images are updated but the notes are not removed.
My code is as follows:
//----- Implementación del evento para el formateo de las celdas -----//
private void rgvResOper_CellFormatting(object sender, CellFormattingEventArgs e)
{
int iRenglon, iColumna, iRenCom, iColCom, iElemento1;
string sDato;
Font MiFont001 = new Font(new FontFamily("Verdana"), 6.0F, FontStyle.Bold);
try
{
Cursor.Current = Cursors.WaitCursor;
//--------------------------------------------------------------------------------------------------------------------//
//----- S e d a f o r m a t o a l a c e l d a q u e s e e n c u e n t r a a c t i v a -----//
//--------------------------------------------------------------------------------------------------------------------//
if (e.CellElement.ViewTemplate.Caption == "Información de las Cuentas Contables afectadas por la Póliza")
{
//e.CellElement.DrawFill = true;
e.CellElement.BackColor = Color.FromArgb(240, 240, 255);
e.CellElement.TableElement.RowHeight = 17;
e.CellElement.NumberOfColors = 1;
}
else if (e.CellElement.ViewTemplate.Caption == "Información de las Pólizas que conforman el Concepto")
{
//e.CellElement.DrawFill = true;
e.CellElement.BackColor = Color.FromArgb(240, 255, 240);
e.CellElement.TableElement.RowHeight = 18;
e.CellElement.NumberOfColors = 1;
}
else if (e.CellElement.ViewTemplate.Caption == "")
{
if (e.CellElement.ColumnInfo.HeaderText == "IdConcepto")
{
e.CellElement.Font = MiFont001;
}
if (e.CellElement.Text == "GROSS PROFIT" ||
e.CellElement.Text == "COST" ||
e.CellElement.Text == "OTHERS COST / PROFITS" ||
e.CellElement.Text == "EXTRA POSITIONS" ||
e.CellElement.Text == "OTHERS" ||
e.CellElement.Text == "PROFIT" ||
e.CellElement.Text == "CASH-FLOW Before Corporate Tax" ||
e.CellElement.Text == "EBITDA" ||
e.CellElement.Text == "EBIT")
{
e.CellElement.ForeColor = Color.Maroon;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------//
//----- S e o b t i e n e l a i n f o r m a c i ó n d e l c o m e n t a r i o p a r a c o l o c a r e l m a r c a d o r -----//
//-------------------------------------------------------------------------------------------------------------------------------------------------//
if (this.dtResComentarios.Rows.Count > 0 && this.rgvResOper.Rows.Count > 0)
{
for (iElemento1 = 0; iElemento1 <= this.dtResComentarios.Rows.Count - 1; iElemento1++)
{
if (this.rrbCifrasMes.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
{
if (this.dtResComentarios.Rows[iElemento1]["DescColumna"].ToString() == e.CellElement.ColumnInfo.FieldName.ToString() &&
(Convert.ToInt32(this.dtResComentarios.Rows[iElemento1]["IdConcepto"]) - 1) == e.CellElement.RowIndex &&
iDeptoTda == Convert.ToInt32(this.dtResComentarios.Rows[iElemento1]["IdCtoUtilidad"]))
{
e.CellElement.Image = Image.FromFile(Application.StartupPath + "\\Imagenes\\Iconos\\Nota2.png");
e.CellElement.ImageAlignment = ContentAlignment.MiddleRight;
e.CellElement.TextImageRelation = TextImageRelation.TextBeforeImage;
e.CellElement.TextAlignment = ContentAlignment.MiddleRight;
}
}
}
}
}
else
{
e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, Telerik.WinControls.ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, Telerik.WinControls.ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.NumberOfColorsProperty, Telerik.WinControls.ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.BackColorProperty, Telerik.WinControls.ValueResetFlags.Local);
}
Cursor.Current = Cursors.Default;
}
catch (Exception ex)
{
Cursor.Current = Cursors.Default;
MessageBox.Show(ex.Message.ToString(), "Emisión de Reportes", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Can you help me please.
Not if worth something if I inform you that I have a license for WinForms controls Tellerik.
Greetings ...
In CellFormating'm formatting the text of GridView and am placing an image in the GridView cells when it has a note or comment.
The problem with it is that sometimes CellFormatting puts the image of the note in cells where it is not and does not remove the image of the note when changing store. The data in the GridView if the images are updated but the notes are not removed.
My code is as follows:
//----- Implementación del evento para el formateo de las celdas -----//
private void rgvResOper_CellFormatting(object sender, CellFormattingEventArgs e)
{
int iRenglon, iColumna, iRenCom, iColCom, iElemento1;
string sDato;
Font MiFont001 = new Font(new FontFamily("Verdana"), 6.0F, FontStyle.Bold);
try
{
Cursor.Current = Cursors.WaitCursor;
//--------------------------------------------------------------------------------------------------------------------//
//----- S e d a f o r m a t o a l a c e l d a q u e s e e n c u e n t r a a c t i v a -----//
//--------------------------------------------------------------------------------------------------------------------//
if (e.CellElement.ViewTemplate.Caption == "Información de las Cuentas Contables afectadas por la Póliza")
{
//e.CellElement.DrawFill = true;
e.CellElement.BackColor = Color.FromArgb(240, 240, 255);
e.CellElement.TableElement.RowHeight = 17;
e.CellElement.NumberOfColors = 1;
}
else if (e.CellElement.ViewTemplate.Caption == "Información de las Pólizas que conforman el Concepto")
{
//e.CellElement.DrawFill = true;
e.CellElement.BackColor = Color.FromArgb(240, 255, 240);
e.CellElement.TableElement.RowHeight = 18;
e.CellElement.NumberOfColors = 1;
}
else if (e.CellElement.ViewTemplate.Caption == "")
{
if (e.CellElement.ColumnInfo.HeaderText == "IdConcepto")
{
e.CellElement.Font = MiFont001;
}
if (e.CellElement.Text == "GROSS PROFIT" ||
e.CellElement.Text == "COST" ||
e.CellElement.Text == "OTHERS COST / PROFITS" ||
e.CellElement.Text == "EXTRA POSITIONS" ||
e.CellElement.Text == "OTHERS" ||
e.CellElement.Text == "PROFIT" ||
e.CellElement.Text == "CASH-FLOW Before Corporate Tax" ||
e.CellElement.Text == "EBITDA" ||
e.CellElement.Text == "EBIT")
{
e.CellElement.ForeColor = Color.Maroon;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------//
//----- S e o b t i e n e l a i n f o r m a c i ó n d e l c o m e n t a r i o p a r a c o l o c a r e l m a r c a d o r -----//
//-------------------------------------------------------------------------------------------------------------------------------------------------//
if (this.dtResComentarios.Rows.Count > 0 && this.rgvResOper.Rows.Count > 0)
{
for (iElemento1 = 0; iElemento1 <= this.dtResComentarios.Rows.Count - 1; iElemento1++)
{
if (this.rrbCifrasMes.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
{
if (this.dtResComentarios.Rows[iElemento1]["DescColumna"].ToString() == e.CellElement.ColumnInfo.FieldName.ToString() &&
(Convert.ToInt32(this.dtResComentarios.Rows[iElemento1]["IdConcepto"]) - 1) == e.CellElement.RowIndex &&
iDeptoTda == Convert.ToInt32(this.dtResComentarios.Rows[iElemento1]["IdCtoUtilidad"]))
{
e.CellElement.Image = Image.FromFile(Application.StartupPath + "\\Imagenes\\Iconos\\Nota2.png");
e.CellElement.ImageAlignment = ContentAlignment.MiddleRight;
e.CellElement.TextImageRelation = TextImageRelation.TextBeforeImage;
e.CellElement.TextAlignment = ContentAlignment.MiddleRight;
}
}
}
}
}
else
{
e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, Telerik.WinControls.ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, Telerik.WinControls.ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.NumberOfColorsProperty, Telerik.WinControls.ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.BackColorProperty, Telerik.WinControls.ValueResetFlags.Local);
}
Cursor.Current = Cursors.Default;
}
catch (Exception ex)
{
Cursor.Current = Cursors.Default;
MessageBox.Show(ex.Message.ToString(), "Emisión de Reportes", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Can you help me please.
Not if worth something if I inform you that I have a license for WinForms controls Tellerik.
Greetings ...