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.
Unfortunately, activation email could not send to your email. Please try again.

Retrieving/Saving Records to Database

Thread ID:

Created:

Updated:

Platform:

Replies:

76534 Sep 11,2008 05:32 AM Sep 16,2008 07:10 AM Windows Forms 6
loading
Tags: GridControl
lg_sony_27
Asked On September 11, 2008 05:32 AM

Hi! Im new to syncfusion and I used VB2005. I am trying to create a grading system.My concerns are very basic...
1. How do retrieve records from my sql?
2. How do I assign formula? programatically (preferred) or through designer if any. Say in column A students name will display, Column B contains total Assign given by the teacher, in Column C teacher will enter scores of each students and in Column C i want to have a formula like =((A1/B1)*60 + 40).
3. Saving any changes to the database



Nisha Arockiya A [Syncfusion]
Replied On September 11, 2008 08:03 AM

Hi,

Thanks for your interest in Syncfusion products.

1)How to retrieve records from my sql?
Initially load the dataset to the grid using the following code snippet.
//load the dataset
this.sqlDataAdapter1.Fill(this.dataSet11);

After loading you can retrieve records from the Grid itself.

2)How do I assign formula?
You can assign formula to a whole column by setting ColStyles[colIndex].Text to specific formula of the FormulaCell celltype.

Me.GridControl1.ColStyles[3].CellType = "FormulaCell"
Me.GridControl1.ColStyles[3].Text = "=((A1/B1)*60 + 40)"



3)Saving any changes to the database

If you are using the VS designer to add your daatset and datatable, if you allow it to generate Update commands, then you only have to call this.sqlDataAdapter1.Update to have the dataadapter move the changes back to the data source. This is analogous to the this.sqlDataAdapter1.Fill command that retrieves the information when the data is originally loaded.

In the samples listed below, there are Form_Closing events taht have commented code in them that would do the update.


Syncfusion\Essential Suite\Grid\Samples\DataBound\GDBGMultiHeader

Syncfusion\Essential Suite\Grid\Samples\DataBound\RecordNavDataBoundGrid


Please let me know any clarifications.

Regards,
Nisha


>Hi! Im new to syncfusion and I used VB2005. I am trying to create a grading system.My concerns are very basic...
1. How do retrieve records from my sql?
2. How do I assign formula? programatically (preferred) or through designer if any. Say in column A students name will display, Column B contains total Assign given by the teacher, in Column C teacher will enter scores of each students and in Column C i want to have a formula like =((A1/B1)*60 + 40).
3. Saving any changes to the database





lg_sony_27
Replied On September 11, 2008 08:14 PM

Thank you for the quick reply. I noticed that you mostly used C# in your sample code here, I am using vb2005 is any possibilities that you show examples in VB?

I have some other concerns.

1. if I have "(A1 + B1)" formula in C1, will this automatically apply/compute for values in A2 and B2 in C2 and so on?
2. how do I create tab sheets?
3. Is there drag and fill (autofill) feature?
4. How do I change the Header value?
5. How to make the cellpointer move to next row when enter key is pressed.
6. Sort columns (ex. Column A - LastName, Column B - FirstName, Column C - Gender. Column C is the primary key sorted Descending and Column A is the secondary key sorted Ascending.


Nisha Arockiya A [Syncfusion]
Replied On September 12, 2008 09:20 AM

Hi,

1. if I have "(A1 + B1)" formula in C1, will this automatically apply/compute for values in A2 and B2 in C2 and so on?
---------------------
You can copy formulas into adjacent cells by using the fill handle (fill handle: The small black square in the lower-right corner of the selection. When you point to the fill handle, the pointer changes to a black cross.) can be achieved by using the ExcelMarkerMouseController, which could be found in the \Syncfusion\Essential Suite\Grid\Samples\In Depth\ExcelSelectionMarker sample, and by setting the FormulaCopyFlags of GridFormulaEngine as mentioned below.


GridFormulaEngine engine = ((GridFormulaCellModel)this.gridControl1.CellModels["FormulaCell"]).Engine;
engine.FormulaCopyFlags |= GridFormulaCopyFlags.ClipBoardReferencesAdjusted;


The first cell value should be copied and pasted in all the dragged cells in the MouseUp event of the ExcelMarkerMouseController.

Please refer to the sample given below which illustrates the above:

http://websamples.syncfusion.com/samples/Grid.Windows/I40755/main.htm

2)How do I create tab sheets?
You can create tab sheets using the following code snippet:

WorkbookModel workbook;
workbook = new WorkbookModel("Workbook");
GridModel sheet1 = new GridModelEx();
SampleGrid.SetupGridModel(sheet1);
workbook.Worksheets.Add(new WorksheetModel(workbook, "Sheet 1", sheet1));


3)Is there drag and fill (autofill) feature?

Please refer to the following browser sample for drag support.

\Syncfusion\EssentialStudio\6.3.0.30\Windows\Grid.Windows\Samples\2.0\DragDropSupport\

Take a look at the Syncfusion\Essential Suite\Grid\Samples\In Depth\ExcelSelectionMarker sample. In that sample, if you position the cursor over the bottom right corner of a cell or selection, you get a special drag cursor that allows you to expand the selection by dragging. When you release the drag, in the sample a message box pops up that gives you the range selected. At that point, you could do your auto-fill. Now the sample does not actually do the autofill, but depending on what you want to do, you could use grid.ChangeCell to change the whole range to have the same style as the top left cell. Or, you could just loop through the range, explicitly setting values in some logical way depending upon what you want.

4) How do I change the Header value?
You can change the column header text using the following code snippet.

if (e.ColIndex == 1 && e.RowIndex == 0)
{
e.Style.Text = "Data Creazione";
}


5)How to make the cellpointer move to next row when enter key is pressed.
For that you need to handle CurrentCellControlKeyMessage event.

private void gridControl1_CurrentCellControlKeyMessage(object sender, GridCurrentCellControlKeyMessageEventArgs e)
{
if(Keys.keyCode == Keys.Enter)
{
this.gridControl1.CurrentCell.MoveTo(ro+1,col);
}
}


6)Sort columns
Please refer this forum thread, which deals with multicolumn sorting in a gridcontrol and let me know if this helps.
Example on How to Multi-Column Sort with GridControl

Please let me know if this helps.

Retgards,
Nisha


>Thank you for the quick reply. I noticed that you mostly used C# in your sample code here, I am using vb2005 is any possibilities that you show examples in VB?

I have some other concerns.

1. if I have "(A1 + B1)" formula in C1, will this automatically apply/compute for values in A2 and B2 in C2 and so on?
2. how do I create tab sheets?
3. Is there drag and fill (autofill) feature?
4. How do I change the Header value?
5. How to make the cellpointer move to next row when enter key is pressed.
6. Sort columns (ex. Column A - LastName, Column B - FirstName, Column C - Gender. Column C is the primary key sorted Descending and Column A is the secondary key sorted Ascending.




lg_sony_27
Replied On September 12, 2008 08:33 PM

Hi!
What I mean by this is, I want that whenever the user will type in values during runtime say in columns A and B the Column C will automatically compute it.

When I put this code
Me.GridControl1.ColStyles[3].CellType = "FormulaCell"
Me.GridControl1.ColStyles[3].Text = "=((A1/B1)*60 + 40)"
The cell reference should be relative. whether the user will input in A50 and B50 it will still compute.

I don't know C#. Can you post the code in its VB equivalent? Thanks!

>Hi,

1. if I have "(A1 + B1)" formula in C1, will this automatically apply/compute for values in A2 and B2 in C2 and so on?
---------------------
You can copy formulas into adjacent cells by using the fill handle (fill handle: The small black square in the lower-right corner of the selection. When you point to the fill handle, the pointer changes to a black cross.) can be achieved by using the ExcelMarkerMouseController, which could be found in the \Syncfusion\Essential Suite\Grid\Samples\In Depth\ExcelSelectionMarker sample, and by setting the FormulaCopyFlags of GridFormulaEngine as mentioned below.


GridFormulaEngine engine = ((GridFormulaCellModel)this.gridControl1.CellModels["FormulaCell"]).Engine;
engine.FormulaCopyFlags |= GridFormulaCopyFlags.ClipBoardReferencesAdjusted;


The first cell value should be copied and pasted in all the dragged cells in the MouseUp event of the ExcelMarkerMouseController.

Please refer to the sample given below which illustrates the above:

http://websamples.syncfusion.com/samples/Grid.Windows/I40755/main.htm






lg_sony_27
Replied On September 12, 2008 09:23 PM

By the way, I will be using the GDBG. I was trying to GridControl but I cant bind it to my datasource.


Nisha Arockiya A [Syncfusion]
Replied On September 16, 2008 07:10 AM

Hi,

Thanks for your updates.

You can set the grid to update references when you copy/paste them by setting this flag in the 2.0 versions.


GridFormulaEngine engine = ((GridFormulaCellModel)this.gridControl1.CellModels["FormulaCell"]).Engine;

engine.FormulaCopyFlags |= GridFormulaCopyFlags.ClipBoardReferencesAdjusted;


Please refer to the following location for the sample code in VB.
http://websamples.syncfusion.com//samples/Grid.Windows/Development/ForumlaDragVB.zip


Please let me know if this helps.

Regards,
Nisha

>By the way, I will be using the GDBG. I was trying to GridControl but I cant bind it to my datasource.




CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;