CellFormatting

4 posts, 0 answers
  1. luca
    luca avatar
    9 posts
    Member since:
    Feb 2008

    Posted 27 Aug 2009 Link to this post

    i want to change a visibility property into an one ore more cell when i adding a new row 

    Private

     

    Sub RadGridView1_CellBeginEdit(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCellCancelEventArgs) Handles RadGridView1.CellBeginEdit

     

     

     

    ' if a value of field-column if "C" 
    dim ValueColum as string=Me.RadGridView1.Rows(RowIndex).Cells(Me.RadGridView1.MasterGridViewTemplate.Columns("ind_tiporiga").Index).Value

     

     

     

    dim i as integer=3 '  this is a indexCell
    Select case ValueColum 
        case "C"
             Me.RadGridView1.Rows(RowIndex).Cells(i).CellElement.Visibility = Telerik.WinControls.ElementVisibility.Collapsed

     

     

     

             Me.RadGridView1.Rows(RowIndex).Cells(i).CellElement.BackColor = Color.Gray

     

     

     

    case Else
            Me.RadGridView1.Rows(RowIndex).Cells(i).CellElement.Visibility = Telerik.WinControls.ElementVisibility.visible

     

            Me.RadGridView1.Rows(RowIndex).Cells(i).CellElement.BackColor = Color.white

    end select
    end sub
    ' This Code don't work please help me
  2. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 01 Sep 2009 Link to this post

    Hello luca,

    Please find the answer to your question in the support ticket that you have opened: Change property cell into new row.

    Essentially, you should use the ViewCellFormatting event to change properties of cells in a new row:
    void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)     
    {     
        if (e.CellElement.ColumnIndex == 0 && e.CellElement.RowInfo is GridViewNewRowInfo)     
        {     
            e.CellElement.BackColor = Color.Gray;     
            e.CellElement.GradientStyle = GradientStyles.Solid;     
            e.CellElement.DrawFill = true;     
        }     

    I hope this helps. If you have additional questions, feel free to contact us.

    All the best,
    Nikolay
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. vahid
    vahid avatar
    7 posts
    Member since:
    May 2016

    Posted 12 Jul Link to this post

    Hi 

    I have used this code for changing the color of particular cell in RadGridView

    if (e.Column.Name == "CATCOLOR")
              {
                  if (e.CellElement.RowInfo.Cells["Color"].Value != DBNull.Value)
                  {
                      e.CellElement.Font = new Font("Segoe UI", 9, FontStyle.Bold);
                      e.CellElement.ForeColor = Color.FromArgb(Convert.ToInt32(e.CellElement.RowInfo.Cells["Color"].Value));
                     // return;
                  }
                  else
                  {
                      e.CellElement.ResetValue(LightVisualElement.ImageProperty, ValueResetFlags.Local);
                      e.CellElement.ResetValue(LightVisualElement.ImageAlignmentProperty, ValueResetFlags.Local);
                      e.CellElement.ResetValue(LightVisualElement.TextImageRelationProperty, ValueResetFlags.Local);
                      e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
                      e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
                      e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local);
                      e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
                      e.CellElement.ResetValue(LightVisualElement.FontProperty, ValueResetFlags.Local);
                  }
              }

    when I using horizental scroll bar for scrolling the colors other cells forecolor changes instead of desired column!

     

  5. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 12 Jul Link to this post

    Hi Vahid,

    Thank you for writing.

    It looks like you need one more else clause handling the case when you are not in the CATCOLOR column. Please check the following example: http://docs.telerik.com/devtools/winforms/gridview/cells/formatting-cells#example-cells-background-formatting.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top