|
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);
}
}
} |
using (Pen pen = new Pen(Color.FromArgb(0, 192, 192), 1)) { e.Graphics.DrawRectangle(pen, e.RowBounds.Left + 1, e.RowBounds.Top, e.RowBounds.Width - 3, e.RowBounds.Height - 1); }
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.)
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
//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
|
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
| |
|
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.
To display Image and Text - https://www.syncfusion.com/kb/6948/how-to-display-a-image-and-text-in-a-cell-in-gridcontrol | |
|
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.
|
Hi,
Added the BrowseOnly at the end and it works.
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.)
|
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.
We have prepared the simple sample to use the Scrollers Frame control in the Grid control. Please refer the following sample for your reference.
Sample link - https://www.syncfusion.com/downloads/support/directtrac/general/ze/GridScrollbarVsScrollersFrame-935069737.zip
Scrollers frame - https://help.syncfusion.com/windowsforms/scrollersframe/getting-started
|
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:
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
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;
|
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.
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.
| ||
|
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.
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.
Sample link - https://www.syncfusion.com/downloads/support/directtrac/general/ze/GridControlWF164405-1081769095.zip
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. |
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.
|
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. |
|
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
|
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; } } }
2. How can i add padding to the top of the row text?
Regards
|
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; |