Hide rows and insert row

Hello:

I have a problem to use gridcontrol when I hide rows and then insert row .

example:
gridcontrol have 5 rows , rows 2 and 3 are hide , when I select row 1 and using InsertRange(1,1),and then hide row will hideing wrong place.

How can I using InsertRange and let the hide row in the right place at the same time?

think for any help.

Best Regards

Quenton



6 Replies

SR Sri Rajan Syncfusion Team July 25, 2008 11:02 AM UTC

Hi Quenton,

Thank you for your interest in Syncfusion products.

You need to hide the rows(2 & 3) before insert. Then only it will hide the rows in the correct places.
Please refer the below code for more details.

this.gridControl1.HideRows[2] = true;
this.gridControl1.HideRows[3] = true;
this.gridControl1.Model.Rows.InsertRange(1, 1);


Please let me know if this helps.

Best Regards,
Srirajan.



AD Administrator Syncfusion Team July 29, 2008 01:19 PM UTC

Hi Srirajan:

Thanks for your response.

My previous example is not clear , I post the simple sample .

' I using gridcontrol and hide row 3 and 4
Public Sub New()
InitializeComponent()
Me.GridControl1.HideRows(3) = True
Me.GridControl1.HideRows(4) = True
End Sub

' Then I using button to insert row
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim Row, Col As Integer
Me.GridControl1.CurrentCell.GetCurrentCell (Row, Col )
Me.GridControl1.Model.Rows.InsertRange(Row, Col )

End Sub

Execute program,Imput any text in row(2),and select row(1) push button to insert row,and previous imput text is disappear .

Because my program must to allow select anywhere to insert.so i get this problem.


Best Regards

Quenton




AD Administrator Syncfusion Team July 29, 2008 01:32 PM UTC

Hi Srirajan:

BY the way , I have another question.
I store data to tag of cell , and using Me.Model.CutPaste.Copy() to copy this cell , but tag was not copied .

How can I copy tag in cell ?


Best Regards

Quenton



SR Sri Rajan Syncfusion Team July 30, 2008 11:38 AM UTC

Hi Quenton,

Thank you for your continued interest in Syncfusion products.

Please try this code to hide rows instead of using HideRows property to solve this issue.

Me.gridControl1.RowHeights(2) = 0 Me.gridControl1.RowHeights(3) = 0


Here is the code to copy forumula.

'Set this in Form_Load event.
Dim model As GridFormulaCellModel = TryCast(Me.gridControl1.CellModels("FormulaCell"), GridFormulaCellModel)
model.Engine.FormulaCopyFlags = model.Engine.FormulaCopyFlags Or GridFormulaCopyFlags.ClipBoardFormula


Please let me know if this helps.

Best Regards,
Srirajan.





AD Administrator Syncfusion Team July 31, 2008 02:37 AM UTC

Hi Srirajan:

Thanks for your response.

The hide row problem is solved.

And I post the example to describe tag problem.

' I declare this class to store my information
Public Class Test
Public no As Integer
Public name As String

Public Sub New(ByVal n As Integer, ByVal name As String)
no = n
name = name
End Sub
End Class


and store this object in tag of cell.

Dim t As New Test(0, "0")
GridControl1(1, 2).Tag = t

then I using CutPaste to copy.
GridControl1.Selections.Ranges.GetRowRanges(GridRangeInfoType.Rows) GridControl1.CutPaste.Model.CutPaste.Copy()

and paste.

GridControl1.CutPaste.Paste()

but tag didn't copy.

How can I copy tag in this situation ?

Best Regards

Quenton



SR Sri Rajan Syncfusion Team July 31, 2008 09:06 AM UTC

Hi Quenton,

Thank you for your interest in Syncfusion products.

If you want to copy/paste cells with tags, then the object that you are using as a Tag must be Serializable (so the Framework can save it to the Clipboard).

One other comment on Tags is that if your object that you are using as a Tag implements ICloneable, then setting an object into the Tag will set a clone into the Tag, and not the actual object.

Here is the minimal sample which implements this task.
http://websamples.syncfusion.com/samples/grid.windows/F75390/main.htm

Please let me know if this helps.

Best Regards,
Srirajan.


Loader.
Up arrow icon