This is a migrated thread and some comments may be shown as answers.

Bottom border missing in selection

1 Answer 77 Views
GridView
This is a migrated thread and some comments may be shown as answers.
konrad
Top achievements
Rank 1
konrad asked on 27 Oct 2014, 11:19 AM
Hi,

Sometimes I'm pedantic when it comes to the appearance of the application.
I have a RadGridView called cGrid with events:

private void cGrid_CellFormatting(object sender, CellFormattingEventArgs e)
{
    // simple background
    e.CellElement.BackColor = Color.FromArgb(186, 220, 230);
    e.CellElement.BackColor2 = e.CellElement.BackColor;
    e.CellElement.BackColor3 = e.CellElement.BackColor;
    e.CellElement.BackColor4 = e.CellElement.BackColor;
    e.CellElement.DrawFill = true;
}

private void cGrid_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    // border color from background
    Color color = e.CellElement.BackColor;
  
    // but if IsCurrent or IsSelected the border color should be red
    if (e.CellElement.IsCurrent || e.CellElement.IsSelected)
    {
        color = Color.Red;
    }
  
    // single border for nice looking
    e.CellElement.BorderBoxStyle = BorderBoxStyle.SingleBorder;
  
    // solid for using only one color
    e.CellElement.BorderGradientStyle = GradientStyles.Solid;
    e.CellElement.BorderColor = color;
  
    e.CellElement.DrawBorder = true;
}



And set:
this.cGrid.EnableHotTracking = false;
this.cGrid.HideSelection = true;
this.cGrid.MultiSelect = true;
this.cGrid.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect;



And now I see by selecting multiple cells (check attachment).
For cells ch last selected row can not see the bottom border.
Do you know a trick to solve this "problem"?

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 30 Oct 2014, 08:38 AM
Hello Dominik,

Thank you for writing.

In the ViewCellFormatting event you set the DrawBorder property to true. Thus, the border will be rendered for all the cells. Note that neighboring cells share common borders and the selected cell's bottom border overlaps with the below cell's top border which has different border color.

I have modified your code from the ViewCellFormatting event in order to display the bottom border for the last selected cell:
private void radGridView1_ViewCellFormatting(object sender,
    Telerik.WinControls.UI.CellFormattingEventArgs e)
{
    Color color = e.CellElement.BackColor;
 
    if (e.CellElement.IsCurrent || e.CellElement.IsSelected)
    {
        color = Color.Red;
    }
    e.CellElement.BorderBoxStyle = BorderBoxStyle.FourBorders;
 
    e.CellElement.BorderBottomWidth = 1;
    e.CellElement.BorderLeftWidth = 1;
    e.CellElement.BorderTopWidth = 1;
    e.CellElement.BorderRightWidth = 1;
 
    e.CellElement.BorderBottomColor = color;
    e.CellElement.BorderBottomShadowColor = color;
    e.CellElement.BorderTopColor = color;
    e.CellElement.BorderTopShadowColor = e.CellElement.BackColor;
    e.CellElement.BorderLeftColor = color;
    e.CellElement.BorderLeftShadowColor = e.CellElement.BackColor;
 
    e.CellElement.BorderRightColor = color;
    e.CellElement.BorderRightShadowColor = e.CellElement.BackColor;
 
    e.CellElement.BorderGradientStyle = GradientStyles.Solid;
    e.CellElement.DrawBorder = true;
}


I hope this information helps. Should you have further questions, I would be glad to help.
 
Regards,
Desislava
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
konrad
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or