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

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

6 Replies

AK Arun Kumar V Syncfusion Team November 6, 2012 11:34 AM UTC

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.



SA Saif Ahmed November 9, 2012 01:39 PM UTC

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


VK Vinish Kumar K Syncfusion Team November 14, 2012 01:02 PM UTC

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


SA Saif Ahmed November 15, 2012 11:46 AM UTC

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


AK Arun Kumar V Syncfusion Team November 16, 2012 07:16 AM UTC

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


SA Saif Ahmed November 19, 2012 11:28 AM UTC

Hi Arun Thank you. The issue is resolved.

Loader.
Up arrow icon