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.

How to set the last row number of grid control to asterisk

Thread ID:

Created:

Updated:

Platform:

Replies:

105477 Oct 29,2012 04:06 AM Nov 19,2012 06:28 AM Windows Forms 6
loading
Tags: GridControl
Saif Ahmed
Asked On October 29, 2012 04:06 AM

Hi 

I have a grid control and on adding a value in the last row, add a row in the end. But I want the last row number as asterisk *. Looking forward for quick response. Thank you.

Regards
Saif

Arun Kumar V [Syncfusion]
Replied On November 6, 2012 06:34 AM

Hi Saif,

 Thanks for your interest in Syncfusion products.

Query:

I want the last row number as asterisk *.

The last row of a gridcontrol can be made with the asterix value or any other value by using the PasswordChar property.

 

Please refer to the following code.

 

Code snippet:

  public Form1()

        {

 

//code..

            for (int row = gridControl1.RowCount-1; row < gridControl1.RowCount; row++)

            {

                for (int col = 1; col < 10; col++)

                {

                    this.gridControl1[row, col].CellType = GridCellTypeName.TextBox;

                    this.gridControl1[row, col].PasswordChar = char.Parse("*");

                }

            }

//code..

 Please let me know if you have any other concerns.

 Regards,

Arun.


Saif Ahmed
Replied On November 9, 2012 08:39 AM

Hi Arun,

Thanks for the reply, I believe I didn't made my question clear. I want the last row as asterisk in Syncfusion grid control not the column type as * . I have attached a screen sort to have a better view. The last empty row is marked as *. I need exactly the same out put in Syncfution grid control. There is no property like AllowUserToAddRows in sync gridControl unlike windowsGrid. Please advice.Once again thank u Arun.



asteriskQuestion_ed5984c9.rar

Vinish Kumar K [Syncfusion]
Replied On November 14, 2012 08:02 AM

Hi Saif,

 

Thanks for your update.

 

Query

AddNew option in GridControl

Now in our GridControl there is no direct property for add new record. But you could easily have this functionality by overriding the grid's OnCurrentCellKeyPress.  Please use the below codes in OnCurrentCellKeyPress.

 

 

Code:

 

if(CurrentCell.RowIndex == RowCount)

                              {

                                    if(CurrentCell.Renderer.ControlText == "")

                                    {

                                          RowCount++;

                            this.Refresh();

                                    }

                              }

 

 

For * symbol in header you can use this in query cell info. Please refer the attached sample file also It will helps to you.

 

 

Please let me know if you have further concerns.

 

Regards,

Vinish.



AddNew in GridControl_7cbe6bef.zip

Saif Ahmed
Replied On November 15, 2012 06:46 AM

Hi Vinish,

Thanks a lot for an early reply. The code is working fine if we don't have the data table bind with the grid. To be more clear my 1st column of the datatable has some values. if I say e.ColIndex ==0 then the asterisk is not displaying. if I say e.ColIndex==1 then it appears in the 1st column of my grid. PFA.

void NdtGrid_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
        {
            if (e.RowIndex == this.RowCount && e.ColIndex == 1)
            {
                e.Style.CellValue = "*";
                e.Style.Font.Bold = true;
                e.Style.Font = new GridFontInfo(new Font(e.Style.GdipFont.FontFamily, 12f));
                e.Style.VerticalAlignment = GridVerticalAlignment.Top;
                e.Style.HorizontalAlignment = GridHorizontalAlignment.Center;
            }
        }  

do I need to keep 1st column of all my data table as empty and update the rowcount values in the grid? or there is some other fix? please advise. Thanks a ton



asteriskQuestion1_192d8640.rar

Arun Kumar V [Syncfusion]
Replied On November 16, 2012 02:16 AM

Hi Saif,

Thanks for the update.

Query:

In the case e.ColIndex ==0 then the asterisk is not displaying, but in the case e.ColIndex==1 it appears in the 1st column of my grid.

I have updated solution for what I had understood. In both the condition the asterix had been displayed.

Note:

The last row can be used for AddNewRecord without obstructing the binded datatable value by using the following strategy.

Code:

//In form load…

{

this.populatethegrid();

//Code..

this.gridControl1.RowCount=this.gridControl1.RowCount+1;

}

Please refer to the attached modified sample file and screen shoot.

Regards,

Arun.



Modified file_9c40963c.zip

Saif Ahmed
Replied On November 19, 2012 06:28 AM

Hi Arun Thank you. The issue is resolved.

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.

;