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.

Grid Control Functioning

Thread ID:

Created:

Updated:

Platform:

Replies:

130798 Jun 3,2017 03:18 AM Jun 14,2017 12:11 AM Windows Forms 6
loading
Tags: GridControl
ShaikhAtikAhmed
Asked On June 4, 2017 01:29 AM

Hey i am not to this control i need to know whether this control can be use as per the user requirement as in i have a invoice form where in in body bard a grid is there no i want to design the grid from code with header name and what will be the data type of the cell now  i want the grid to have developer defined columns and when form i loaded there should be only one row after header row, Some column will have key-down event where a new form will be displayed and that data will be displayed on that column and when user is on the last column if some condition is true than only it should add a new row.grid will have 10 columns and a predefined caption for every column header.here is the example srnoNameCodePartyProductrateqtyAmountgross amtdiscountInvoice Amt1one this column if value is there on product column then only it should add a second row with the sr no as 2 other wise it hsould not add a new row2

Mohanraj Gunasekaran [Syncfusion]
Replied On June 5, 2017 01:44 PM

Hi shkhtk, 
 
Thanks for using Syncfusion product. 
 
We can understand your scenario. We have prepared the sample based on our requirement by using the custom form (Invoice form) in GridControl. It will show while clicking on the Product column. Please refer to the below code example and the sample, 
 
Code example 
this.gridControl1.MouseDown += gridControl1_MouseDown; 
 
void gridControl1_MouseDown(object sender, MouseEventArgs e) 
{ 
    GridCurrentCell currentCell = this.gridControl1.CurrentCell; 
    if (currentCell.ColIndex == 5) 
    { 
        invoiceForm = new InvoiceForm(); 
        invoiceForm.Load += f_Load; 
        invoiceForm.ok.Click += ok_Click; 
        invoiceForm.cancel.Click += cancel_Click; 
        invoiceForm.ShowDialog(); 
    } 
} 
 
void ok_Click(object sender, EventArgs e) 
{ 
   if (!String.IsNullOrEmpty(invoiceForm.product.Text) && invoiceForm.srno.Text == rowIndex.ToString()) 
    { 
        this.gridControl1[rowIndex, 1].CellValue = invoiceForm.srno.Text; 
        this.gridControl1[rowIndex, 2].CellValue = invoiceForm.name.Text; 
        this.gridControl1[rowIndex, 3].CellValue = invoiceForm.code.Text; 
        this.gridControl1[rowIndex, 4].CellValue = invoiceForm.party.Text; 
        this.gridControl1[rowIndex, 5].CellValue = invoiceForm.product.Text; 
        this.gridControl1[rowIndex, 6].CellValue = invoiceForm.rate.Text; 
        this.gridControl1[rowIndex, 7].CellValue = invoiceForm.qty.Text; 
        this.gridControl1[rowIndex, 8].CellValue = invoiceForm.amount.Text; 
        this.gridControl1[rowIndex, 9].CellValue = invoiceForm.grossamount.Text; 
        this.gridControl1[rowIndex, 10].CellValue = invoiceForm.discount.Text; 
        this.gridControl1.Rows.InsertRange(rowIndex+1, 1); 
        rowIndex++; 
        invoiceForm.Dispose(); 
        invoiceForm.Close(); 
    } 
} 
 
Sample link: GridControl 
 
Please let us know, if we misunderstood your scenario 
 
Regards, 
Mohanraj G 


ShaikhAtikAhmed
Replied On June 9, 2017 03:23 AM

i didn't got you,
my scenario is
1) when form/web form is loaded it display grid column (A,B,C) as per developer defined column header eg(A will be "Code",B will be "Product Name ", C will be "Rate" and so on ).
2) and when the form is loaded there will be only one o Row + the header columns.
3) now when user is on Code column he will hit enter and new form will be show and he will select the product from that dialog and when clicked on ok the cell value of the current row and column (code,product name ,Rate will be reflected from the selected record ).
4)and now user is on last column of the row and he hit enter then a new row will be added step(1,2,3,4) follows .

as in my previous company the were using farpoint spread and it was very easily applicable on that, now i wont to implement that thing on your product .
So help  me out,
for your comment , I got your point, it something like that only but your Ok_click should be called on particular column only


ShaikhAtikAhmed
Replied On June 9, 2017 07:23 AM

Hi shkhtk, 
 
Thanks for using Syncfusion product. 
 
We can understand your scenario. We have prepared the sample based on our requirement by using the custom form (Invoice form) in GridControl. It will show while clicking on the Product column. Please refer to the below code example and the sample, 
 
Code example 
this.gridControl1.MouseDown += gridControl1_MouseDown; 
 
void gridControl1_MouseDown(object sender, MouseEventArgs e) 
{ 
    GridCurrentCell currentCell = this.gridControl1.CurrentCell; 
    if (currentCell.ColIndex == 5) 
    { 
        invoiceForm = new InvoiceForm(); 
        invoiceForm.Load += f_Load; 
        invoiceForm.ok.Click += ok_Click; 
        invoiceForm.cancel.Click += cancel_Click; 
        invoiceForm.ShowDialog(); 
    } 
} 
 
void ok_Click(object sender, EventArgs e) 
{ 
   if (!String.IsNullOrEmpty(invoiceForm.product.Text) && invoiceForm.srno.Text == rowIndex.ToString()) 
    { 
        this.gridControl1[rowIndex, 1].CellValue = invoiceForm.srno.Text; 
        this.gridControl1[rowIndex, 2].CellValue = invoiceForm.name.Text; 
        this.gridControl1[rowIndex, 3].CellValue = invoiceForm.code.Text; 
        this.gridControl1[rowIndex, 4].CellValue = invoiceForm.party.Text; 
        this.gridControl1[rowIndex, 5].CellValue = invoiceForm.product.Text; 
        this.gridControl1[rowIndex, 6].CellValue = invoiceForm.rate.Text; 
        this.gridControl1[rowIndex, 7].CellValue = invoiceForm.qty.Text; 
        this.gridControl1[rowIndex, 8].CellValue = invoiceForm.amount.Text; 
        this.gridControl1[rowIndex, 9].CellValue = invoiceForm.grossamount.Text; 
        this.gridControl1[rowIndex, 10].CellValue = invoiceForm.discount.Text; 
        this.gridControl1.Rows.InsertRange(rowIndex+1, 1); 
        rowIndex++; 
        invoiceForm.Dispose(); 
        invoiceForm.Close(); 
    } 
} 
 
Sample link: GridControl 
 
Please let us know, if we misunderstood your scenario 
 
Regards, 
Mohanraj G 


An i also need that i define the celltype of the grid,
eg i need to the colindex 3 always be checkbook,4 will be date , 5 will be combobox and with databind to that combobox, and i also wont to change the color of the header of the grid.i am going through you documentation.


Mohanraj Gunasekaran [Syncfusion]
Replied On June 12, 2017 06:56 AM

Hi shkhtk, 

Sorry for the inconvenience caused. 

Query 
Solution 
when form/web form is loaded it display grid column (A,B,C) as per developer defined column header eg(A will be "Code",B will be "Product Name ", C will be "Rate" and so on ). 
In order to use the header values from the data table, you can use the PopulateHeaders method. Please refer to the below code example, 

Code example 
this.gridControl1.PopulateHeaders(GridRangeInfo.Cells(0, 1, gridControl1.RowCount, gridControl1.ColCount), dt); 
 
when the form is loaded there will be only one o Row + the header columns. 
If you want to load the only one row in grid, you can use the RowCount property. Please rerefer to the below code example, 

Code example 
this.gridControl1.RowCount = 1; 
now when user is on Code column he will hit enter and new form will be show and he will select the product from that dialog and when clicked on ok the cell value of the current row and column (code,product name ,Rate will be reflected from the selected record ). 
and now user is on last column of the row and he hit enter then a new row will be added step(1,2,3,4) follows . 
In order to achieve your scenario, you can use the KeyDown event. Please refer to the below code example 

Code example 
this.gridControl1.KeyDown += gridControl1_KeyDown; 
 
void gridControl1_KeyDown(object sender, KeyEventArgs e) 
{ 
    GridCurrentCell currentCell = this.gridControl1.CurrentCell; 
    if (currentCell.RowIndex == rowIndex && currentCell.ColIndex == 1  && e.KeyData == Keys.Enter) 
    { 
        invoiceForm = new InvoiceForm(); 
        invoiceForm.Load += f_Load; 
        invoiceForm.ok.Click += ok_Click; 
        invoiceForm.cancel.Click += cancel_Click; 
        invoiceForm.ShowDialog(); 
    } 
    else if (currentCell.ColIndex == 10 && (!String.IsNullOrEmpty(invoiceForm.product.SelectedItem.ToString()) && this.gridControl1[rowIndex,1].CellValue.ToString() == rowIndex.ToString())) 
    { 
        this.gridControl1.Rows.InsertRange(rowIndex , 1); 
    } 
}  
 i need to the colindex 3 always be checkbook,4 will be date , 5 will be combobox and with databind to that combobox, 
In order to set the CellType for specific columns, you can use the CellType property in QueryCellInfo event. Please refer to the below code example, 

Code example 
this.gridControl1.QueryCellInfo += gridControl1_QueryCellInfo; 
 
void gridControl1_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) 
{ 
    if (e.RowIndex > 0) 
    { 
        if (e.ColIndex == 3) 
        { 
            e.Style.Description = "Male"; 
            e.Style.CellType = "CheckBox"; 
            e.Style.CheckBoxOptions = new GridCheckBoxCellInfo("true", "false", "", false); 
        } 
        else if (e.ColIndex == 4) 
            e.Style.CellValueType = typeof(DateTime); 
        else if (e.ColIndex == 5) 
            e.Style.CellType = "ComboBox"; 
    } 
} 
 i also wont to change the color of the header of the grid.i am going through you documentation. 

In our previous update, we have enabled the themes so only the header color has changed. In order to avoid this settings for grid, you can disable the themes setting by using the ThemesEnabled property. Please refer to the below code example, 

Code example 
this.gridControl1.ThemesEnabled = false; 
 

Sample link: GridControl 

Regards, 
Mohanraj G 
 


ShaikhAtikAhmed
Replied On June 13, 2017 12:52 AM

Thanks man i was looking for the same. Now will do my implementation and if have any issue will revert back to you.

Mohanraj Gunasekaran [Syncfusion]
Replied On June 14, 2017 12:11 AM

Hi shkhtk,
 
Thanks for your update. 
 
We are glad to know that you got an idea for your implementation. 
 
Please let us know, if you have any concerns. 
 
Regards, 
Mohanraj G  


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.

;