We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

A bunch of questions...

How do I get rid of the column and row headers properly. I can sort of do it in code by doing the following: grdTest.Cols.HeaderCount = -1 grdTest.Rows.HeaderCount = -1 But this does not completely change the cells in the first row and first column to regular cells. The background for these cells changes to white, but the borders remain thick. Also, when clicking on a "covered" cell, is it possible to determine which cell you would be clicking on if the cells were not covered by the one big covering cell (that is, if the cells were not merged)? And finally, how do you apply base styles to portions of the grid? From what I can gather from the difficult to understand VSCC documents, it seems as though I should be using the ChangeCells method of the grid, passing it a GridRangeInfo and a style.

4 Replies

AD Administrator Syncfusion Team February 25, 2003 08:33 PM UTC

To hide the header row and column, you can hide row 0 and column 0.
Me.GridControl1.HideCols(0) = True
Me.GridControl1.HideRows(0) = True
Here are a couple of ways you can get the cell that was clicked even if the cell is part of a covered cell.
Private Sub GridControl1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridControl1.Click
	Dim row, col As Integer
	Dim pt As Point = Me.GridControl1.PointToClient(Control.MousePosition)
	Me.GridControl1.PointToRowCol(pt, row, col)
	Console.WriteLine(row.ToString() + "  " + col.ToString())
End Sub

Private Sub GridControl1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GridControl1.MouseDown
	Dim row, col As Integer
	Dim pt As Point = New Point(e.X, e.Y)
	Me.GridControl1.PointToRowCol(pt, row, col)
	Console.WriteLine(row.ToString() + " x " + col.ToString())
End Sub
Here are some code snippets that show you how you can create a basestyle, and then apply to some cells.
Imports Syncfusion.Windows.Forms.Grid
Imports Syncfusion.Styles

...


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'create a basestyle
        Dim bStyle As GridBaseStyle = New GridBaseStyle("BoldRed", False)
        bStyle.StyleInfo.TextColor = Color.Red
        bStyle.StyleInfo.Font.Bold = True
        bStyle.StyleInfo.BackColor = Color.LightPink
        'add it to the grid's basestyles
        Me.GridControl1.BaseStylesMap.AddRange(New GridBaseStyle() {bStyle})

        'apply style to 1,1,2,2 and 1, 4
        Dim style As New GridStyleInfo()
        style.BaseStyle = "BoldRed"
        Me.GridControl1.ChangeCells(GridRangeInfo.Cells(1, 1, 2, 2), style, StyleModifyType.Override)
        Me.GridControl1(1, 4).BaseStyle = "BoldRed"
End Sub


MS Maxim Software Systems February 26, 2003 12:01 PM UTC

Thanks for the response! > To hide the header row and column, you can hide row 0 and column 0. Hiding the header row and column does not solve my problem. I want to be able to use the 0th row and column as I would any other row or column. > Here are some code snippets that show you how you can create a basestyle, and then apply to some cells. Sorry, I meant to ask how to apply the default base styles built into each grid, or base styles that were created for the grid at design time (e.g. the "Standard" style).


MS Maxim Software Systems February 26, 2003 12:03 PM UTC

> > Here are some code snippets that show you how you can create a basestyle, and then apply to some cells. > > Sorry, I meant to ask how to apply the default base styles built into each grid, or base styles that were created for the grid at design time (e.g. the "Standard" style). Never mind, I think I understand how those base styles work now.


AD Administrator Syncfusion Team February 26, 2003 01:05 PM UTC

To make the header cells look like teh standard cells, try this code.
GridStyleInfo standard = this.gridControl1.BaseStylesMap["Standard"].StyleInfo;;
GridStyleInfo style = this.gridControl1.BaseStylesMap["Row Header"].StyleInfo;
style.Borders = standard.Borders;
style.BackColor = standard.BackColor;

style = this.gridControl1.BaseStylesMap["Header"].StyleInfo;
style.Borders = standard.Borders;
style.BackColor = standard.BackColor;

Loader.
Live Chat Icon For mobile
Up arrow icon