Full row selection completely in 1 color

Hello,
is it possible at all?

I want the full row selection without the border of the selected cell in that row. The selected row should completly appear in 1 color like in a standard DataGridView.

Regards

15 Replies 1 reply marked as answer

BT Balamurugan Thirumalaikumar Syncfusion Team April 12, 2021 11:44 AM UTC

Hi Youki, 
 
Thank you for your interest in Syncfusion products. 
 
We have checked the reported query from our end.  You can  achieve your requirement by using “AlphaBlendSelectionColor” property which update the selection for selected the row. When you want to set the BackColor of current cell like the other selected cells then, you have to use the CellDrawn event. You can refer the following code snippet for your reference. 
 
Code Snippet(C#) 
this.gridControl1.ListBoxSelectionMode = SelectionMode.One; 
this.gridControl1.AllowSelection = GridSelectionFlags.AlphaBlend | GridSelectionFlags.Row; 
this.gridControl1.Model.Options.AlphaBlendSelectionColor = Color.Red; 
//To hide cell current cell border 
this.gridControl1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.HideAlways; 
//Event Subscription 
this.gridControl1.CellDrawn += gridControl1_CellDrawn; 
 
//Event Customization 
void gridControl1_CellDrawn(object sender, Syncfusion.Windows.Forms.Grid.GridDrawCellEventArgs e) 
        { 
            //get the currentcell 
            GridCurrentCell cc = this.gridControl1.CurrentCell; 
            if (e.RowIndex == cc.RowIndex && e.ColIndex == cc.ColIndex) 
            { 
                //fill the selection color to the cells background 
                using (SolidBrush br = new SolidBrush(this.gridControl1.AlphaBlendSelectionColor)) 
                { 
                    e.Graphics.FillRectangle(br, e.Bounds); 
                } 
            } 
        } 
 
 
 
 
Screenshot: 
 
 
 
Please let us know if you would require any other assistance. we will be happy to assist you. 
 
Regards, 
Balamurugan Thirumalaikumar 



YO Youki June 12, 2021 02:51 PM UTC

Hello,
Thanks for the support.
I think i've didn't explained it properly.
I need a gridview with just 3 columns (checkbox & text) without the rowheaders.
Actually just a normal gridview  for only customizing the colors (especially the scrollbar).

I've tried your example but it doesn't work if i'm clicking into the gridview cell. 
The gridview is set to read only but the mouse clicking selects the clicked cell and shows a flickering cursor.
Did i do something wrong?!

I'm using the following code in a standard windows forms gridview.
using (Pen pen = new Pen(Color.FromArgb(0192192), 1))
               {
                   e.Graphics.DrawRectangle(pen, e.RowBounds.Left + 1, e.RowBounds.Top, e.RowBounds.Width - 3, e.RowBounds.Height - 1);
               }

Regards




BT Balamurugan Thirumalaikumar Syncfusion Team June 14, 2021 06:14 PM UTC

Hi Youki, 

Thank you for your update.   

We have checked your query at our end. Based on the information provided, we assume you are trying to select a row with one colour, and the cell shouldn't be flickering when you click on it. Use the BrowseOnly property to disable the editing mode for the entire grid if you don't want the cell to go into flickering mode when you click on it. You can refer the following Documentation for your reference. 


If we misunderstood your query please get back us with video or image clip of your requirement. It will more help us to provide you the earliest solution. 

Please let us know if you would require any other assistance. we will be happy to assist you 

Balamurugan Thirumalaikumar  



Marked as answer

YO Youki June 30, 2021 02:57 PM UTC

Hello,

What am i missing?

If i add your code the string values aren't displayed anymore.

EDIT: It works as long as it's "BrowseOnly" false but i need it for my initial request.

(I need a grid control with full row selection where i can customize all colors and need to add images as cell values later, if i can customize the design as wanted. Also need to try a multiline cell to add text in 2 lines with different font style and maybe further styling - something like name in the 1st line with bold text and a description in the 2nd line.)


Snippet
this.gridControl2.ListBoxSelectionMode = SelectionMode.One;
           this.gridControl2.AllowSelection = GridSelectionFlags.AlphaBlend | GridSelectionFlags.Row;
           this.gridControl2.Model.Options.AlphaBlendSelectionColor = Color.Red;
           //To hide cell current cell border 
           this.gridControl2.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.HideAlways;
           //Event Subscription 
           this.gridControl2.CellDrawn += gridControl2_CellDrawn;


I add values with the following code and it's displayed as long as it's "BrowseOnly" false.

           gridControl2.ColWidths[1] = 45;
           gridControl2.ColWidths[2] = 270; // Full width wanted here
Snippet
//Looping through the cells and assigning the values based on row and column index
           for (int i = 1; i <= list.Count; i++)
           {
               for (int col = 1; col <= gridControl2.ColCount; col++)
               {
                   gridControl2.Model[i, col].CellValue = "test";
               }
           }

Regards



BT Balamurugan Thirumalaikumar Syncfusion Team July 1, 2021 09:19 AM UTC

Hi Youki, 

Thank you for your update. Please refer the following details. 

If i add your code the string values aren't displayed anymore. 

EDIT: It works as long as it's "BrowseOnly" false  
We would like to let you know that the BrowseOnly property can be used to disable the editing mode and prevent to set the cell value for the entire grid. To avoid the reported scenario, we suggest you to set the cell value first, then enabling the BrowseOnly property to disable editing mode. 

I need a grid control with full row selection where i can customize all colors 
As we updated earlier, if you want to change color of  selected row in a grid, you can use “AlphaBlendSelectionColor” property. Please refer the below code, 

Code Snippet 
this.gridControl1.Model.Options.AlphaBlendSelectionColor = Color.Red; 
 
need to add images as cell values later, if i can customize the design as wanted. 
If you want to set a images in cell values, make use of the ImageCellType and add ImageList. 
Please refer the following links for your reference. 


Also need to try a multiline cell to add text in 2 lines with different font style and maybe further styling - something like name in the 1st line with bold text and a description in the 2nd line 
You can add the multiline cell with different fonts by using RichTextBox celltype. Please refer the following link to add RichTextBix cell type. 


Please let us know if you would require any other assistance. we will be happy to assist you. 

Regards 
Balamurugan.Thirumalaikumar


YO Youki July 3, 2021 10:33 AM UTC

Hi,

Added the BrowseOnly at the end and it works.

  1. I wanted to check the design options, after I used CTRL + Z to undo some changes the gridview (gridControl2) disapeared of the Form1.cs [Design] suddenly.

Not visible anymore, debugged again, restarted Visual Studio, doesn't helped. :(



2. Is there a general rule for allowing the use of the properties in the properties window in Visual Studio in the ThemeStyle category? (Sorry, it doesn't has no effect and i can't find specific information in the documentation.)

3. Is it technically possible to use the ScrollBar Frame control with the grid control for customizing the design?

(My goal is a gridview and a vertical scroll bar only with the scroll bar thumb button visible like in the following image [WhatsApp Desktop]. The thumb button can be scrolled up to the top of the first row and vice versa for the last row, there is no space left for the arrows because they are not needed.)





BT Balamurugan Thirumalaikumar Syncfusion Team July 5, 2021 12:44 PM UTC

Hi Youki, 

Thank you for the update. 

We have checked your query at our end. Please refer the following details. 

I wanted to check the design options, after I used CTRL + Z to undo some changes the gridview (gridControl2) disapeared of the Form1.cs [Design] suddenly. 
Please refer the following link to solve the Windows Forms Designer related errors. 

Is there a general rule for allowing the use of the properties in the properties window in Visual Studio in the ThemeStyle category? (Sorry, it doesn't has no effect and i can't find specific information in the documentation.) 
Based on the provided details we have checked your query at our end. But we are little unclear with this query. We are assuming that you are trying to change the VisualStyle of Grid control. If this is the case, please refer the following documentation to set the Grid control visual style. 

Is it technically possible to use the ScrollBar Frame control with the grid control for customizing the design? 
Yes, you can use the Scrollers Frame control as Grid control scroll bar by using Attached to property. 

scrollersFrame1.AttachedTo = gridControl1; 

We have prepared the simple sample to use the Scrollers Frame control in the Grid control. Please refer the following sample for your reference. 




Please let us know if you require further assistance from us. 

Thanks & Regards, 
Balamurugan Thirumalaikumar


YO Youki July 16, 2021 10:42 AM UTC

Hello,

For now I'm trying to use the grid control with customized colors. (Ok, now i get it that it's not working properly by the properties view with all of your controls and it's better to define it all by code.)


I'm using the following code and as you can see, if the column header is disabled the grid shows the 1st row but the scroll thumb is not getting up to border of the arrow box, bug?!


16 July:

  1. Additionally, I can't change the forecolor by the properties view, not by "Edit" on the gridview and also not by code


gridControl1.ForeColor = Color.White;


2. This syncfusion grid control is on a form which is in a panel in front of another form (by the BringToFront method) that have 2 standard windows forms datagridviews. They are flickering as soon as i scroll in the syncfusion's grid control. I had the same issue before but i can't remember how i solved it. I disabled something in your grid control.


Regards




Snippet
gridControl1.HScrollBehavior = GridScrollbarMode.Disabled;
gridControl1.ListBoxSelectionMode = SelectionMode.One;
gridControl1.AllowSelection = GridSelectionFlags.AlphaBlend | GridSelectionFlags.Row;
gridControl1.Model.Options.AlphaBlendSelectionColor = Color.Red;
//To hide cell current cell border 
gridControl1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.HideAlways;
gridControl1.Properties.BackgroundColor = Color.Red;
gridControl1.HScrollBehavior = GridScrollbarMode.Disabled;
gridControl1.ShowColumnHeaders = false;
gridControl1.ShowRowHeaders = false;
//Event Subscription 
gridControl1.CellDrawn += gridControl1_CellDrawn;
gridControl1.VScrollBehavior = GridScrollbarMode.Automatic;
gridControl1.MetroColorTable.ScrollerBackground = Color.Aqua;
gridControl1.MetroColorTable.ArrowNormalBackGround = Color.Green;
gridControl1.MetroColorTable.ThumbNormal = Color.Blue;
gridControl1.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Metro;
gridControl1.ThemesEnabled = true;

gridControl1.Model.Options.DefaultGridBorderStyle = GridBorderStyle.None;
 
for (int i = 1; i <= 10; i++)
{
 
    gridControl1.Model[i, 1].CellValue = "test";
 
}
 
gridControl1.BrowseOnly = true;



BT Balamurugan Thirumalaikumar Syncfusion Team July 16, 2021 02:07 PM UTC

Hi Youki, 
 
Thank you for the update. 
 
We have checked your query at our end. please refer the following details. 
 
I'm using the following code and as you can see, if the column header is disabled the grid shows the 1st row but the scroll thumb is not getting up to border of the arrow box, bug?! 
We could reproduce the reported scenario at our end. we have forwarded this query to our development team for further validation. Will provide you the proper details on July 20,2021. We appreciate your patience till then. 
Additionally, I can't change the forecolor by the properties view, not by "Edit" on the gridview and also not by code 
If you want to change the forecolor of grid control in properties view we suggest you to change the textcolor property inside the BaseStylesMap. 
 
GridControl Propertywindow->BaseStylesMap->Standard->TextColor 
 
If you want to change the forecolor by code, you can change it by using the textcolor property inside the TableStyle. Please refer the code snippet below. 
 
gridControl1.TableStyle.TextColor = Color.Red; 
 
This syncfusion grid control is on a form which is in a panel in front of another form (by the BringToFront method) that have 2 standard windows forms datagridviews. They are flickering as soon as i scroll in the syncfusion's grid control. I had the same issue before but i can't remember how i solved it. I disabled something in your grid control. 
Based on the provided replication procedure we have prepared the simple sample. 
  1. Created form with 2 datagridviews(Form 1).
  2. Created another form and added grid control inside the panel(Form 2).
  3. I have used all provided code snippet in gridcontrol.
  4. Opened Form 2 from Form 1(by the BringToFront method).
We regret that to let you know that we couldn’t reproduce the reported flickering scenario at our end. Please refer the following sample for your reference. 
 
 
Please have a look at this sample and let us know if we have missed you have done in your application. Otherwise try to reproduce the reported issue in this sample and revert to us with the modified sample. It will be more helpful for us to provide a prompt solution at earlier. 
 
Please let us know if you need any other assistance on this. 
 
Balamurugan Thirumalaikumar  
 



YO Youki July 17, 2021 10:36 AM UTC

Hello,

To the last point with the flickering.

I have a form with 2 standard gridviews and a sliding menu as follows.

I'm adding a panel at runtime to the first form and add the second form with the syncfusion's grid control to to the panel.

Hmm, will try to check all properties by deactivatiing.

Regards.




BT Balamurugan Thirumalaikumar Syncfusion Team July 19, 2021 07:38 AM UTC

Hi Youki, 

Thank you for the update. 

Hmm, will try to check all properties by deactivatiing. 
We will wait until here from you. 
I'm using the following code and as you can see, if the column header is disabled the grid shows the 1st row but the scroll thumb is not getting up to border of the arrow box, bug?! 
We are validating this scenario at our end. we will provide the details on July 20,2021 as promised. We appreciate your patience till then. 

In the future, please create a new forum/incident for new queries. 

Balamurugan Thirumalaikumar  




BT Balamurugan Thirumalaikumar Syncfusion Team July 20, 2021 11:15 AM UTC

Hi Youki, 
 
Thank you for your patience. 
 
I'm using the following code and as you can see, if the column header is disabled the grid shows the 1st row but the scroll thumb is not getting up to border of the arrow box, bug?! 
We have checked your query at our end. When the column header is disabled, we suggest you to changing the scroll thumb position using the scrollbar value changed event. Please refer the following code snippet for your reference. 

Code Snippet 
//Event Subscription 
this.gridControl1.VScrollBar.ValueChanged += VScrollBar_ValueChanged; 
 
//Event Customization 
private void VScrollBar_ValueChanged(object sender, System.EventArgs e) 
{ 
    if (gridControl1.TopRowIndex == 1 && !gridControl1.ShowColumnHeaders) 
    { 
        gridControl1.VScrollBar.Value = 0; 
    } 
} 
 
 
 
Please let us know if you would require any other assistance. we will be happy to assist you. 

Thanks & Regards, 
Balamurugan Thirumalaikumar


YO Youki replied to Balamurugan Thirumalaikumar August 4, 2021 08:49 PM UTC

Hi again :),

If i start the app, i can scroll up to the top once but after that scrolling is not possible anymore!

(By the way, i could fix the flickering by doubleBuffering!)

Regards


Example with all your help:


public partial class Form2 : Form
   {
       public Form2()
       {
           InitializeComponent();
 
           this.gridControl1.ListBoxSelectionMode = SelectionMode.One;
           this.gridControl1.AllowSelection = GridSelectionFlags.AlphaBlend | GridSelectionFlags.Row;
           this.gridControl1.Model.Options.AlphaBlendSelectionColor = Color.Green;
           //To hide cell current cell border 
           this.gridControl1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.HideAlways;
 
 
           gridControl1.TableStyle.TextColor = Color.White;
           gridControl1.ShowColumnHeaders = false;
           gridControl1.ShowRowHeaders = false;
 
           //gridControl1.T = Color.White;
           gridControl1.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Metro;
           gridControl1.MetroColorTable.ScrollerBackground = Color.FromArgb(30, 30, 30);
           gridControl1.MetroColorTable.ArrowNormalBackGround = Color.FromArgb(30, 30, 30);
           gridControl1.MetroColorTable.ThumbNormal = Color.Gray;
 
           gridControl1.RowCount = 15;
           gridControl1.ColCount = 4;
           //Looping through the cells and assigning the values based on row and column index
           for (int row = 1; row <= gridControl1.RowCount; row++)
           {
               for (int col = 1; col <= gridControl1.ColCount; col++)
               {
                   gridControl1.Model[row, col].CellValue = string.Format("{0}/{1}", row, col);
               }
           }
 
           gridControl1.BrowseOnly = true;
 
           this.gridControl1.Selections.Add(GridRangeInfo.Row(1));
 
           //Event Subscription 
           this.gridControl1.CellDrawn += gridControl1_CellDrawn;
           //Event Subscription 
           this.gridControl1.VScrollBar.ValueChanged += VScrollBar_ValueChanged;
       }
 
       private void gridControl1_CellDrawn(object sender, GridDrawCellEventArgs e)
       {
           //get the currentcell 
           GridCurrentCell cc = this.gridControl1.CurrentCell;
           if (e.RowIndex == cc.RowIndex && e.ColIndex == cc.ColIndex)
           {
               //fill the selection color to the cells background 
               using (SolidBrush br = new SolidBrush(this.gridControl1.AlphaBlendSelectionColor))
               {
                   e.Graphics.FillRectangle(br, e.Bounds);
               }
           }
       }
 
       //Event Customization 
       private void VScrollBar_ValueChanged(object sender, System.EventArgs e)
       {
           if (gridControl1.TopRowIndex == 1 && !gridControl1.ShowColumnHeaders)
           {
               gridControl1.VScrollBar.Value = 0;
           }
       }
   }


YO Youki replied to Young Kim August 4, 2021 09:25 PM UTC

2. How can i add padding to the top of the row text?



Regards



BT Balamurugan Thirumalaikumar Syncfusion Team August 5, 2021 12:06 PM UTC

Hi Youki, 

Thank you for the update. 

We have checked your query “How can i add padding to the top of the row text?” at our end. In order to set the padding for cell contents, we suggest you use the StyleInfo.TextMargins property. you can refer the following code snippet for your reference. 

Code Snippet 
this.gridControl1.BaseStylesMap["Column Header"].StyleInfo.TextMargins.Top = 15; 
this.gridControl1.BaseStylesMap["Column Header"].StyleInfo.TextMargins.Left = 30; 
// Align the text to center 
this.gridControl1.BaseStylesMap["Column Header"].StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Center; 
 

Please refer the following KB article for more reference. 


Please let us know if you would require any other assistance. we will be happy to assist you and in the future, please create a new forum/incident for new queries.. 

Thanks & Regards, 
Balamurugan Thirumalaikumar  
 


Loader.
Up arrow icon