Issue when i try change to rowheader display text


i try this code and it's trow exception from Program.cs

this
.sfDataGrid1.DrawCell += SfDataGrid1_DrawCell; private void SfDataGrid1_DrawCell(object sender, DrawCellEventArgs e) { if (sfDataGrid1.ShowRowHeader && e.RowIndex != 0) { if (e.ColumnIndex == 0) { e.DisplayText = e.RowIndex.ToString(); } } }

10 Replies

FP Farjana Parveen Ayubb Syncfusion Team June 6, 2018 11:57 AM UTC

Hi Eren,  
  
Thanks for contacting Syncfusion support.  
  
We were able to reproduce the reported issue and logged a bug report for the issue. The fix for the issue will be included in our 2018_Volume2_SP1 release, estimated to be avail at the end of June and the date for 2018_Volume2_SP1 will be planned after our 2018_Volume2 main release.  
  
Please let us know, if you have any concerns.  
  
Regards,  
Farjana Parveen A 



ER Eren June 6, 2018 02:12 PM UTC

there is another issue when I add a new row if add new row position is fixed at the bottom, it makes an empty record but fixed at the top it isn't




AR Amal Raj U Syncfusion Team June 7, 2018 11:20 AM UTC

Hi Eren, 

Thanks for your update. 

By default, AddNewRowPosition denotes the position of the AddNew row only and the rows added from AddNewRow will be added as a last record (End of rows). By using the NewItemPlaceholderPosition property in SfDataGrid, newly added row position can be changed. 
  
Code Example: 
this.sfDataGrid.AddNewRowPosition = RowPosition.FixedTop; 
this.sfDataGrid.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtBeginning; 

or  

this.sfDataGrid.AddNewRowPosition = RowPosition.FixedBottom; 
this.sfDataGrid.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtEnd; 

Please refer to the below user guide document to change the newly added item position, 


Regards, 
Amal Raj U. 



ER Eren June 9, 2018 10:19 AM UTC

Thank you but this not my question. My question is if i press enter when adding new record it makes empty record
and some time if click add new row cell and typing it's trow exception from program.cs

i take a screen shot from exception

I solved the first problem this code but second problem not solved

is have any other solution for first issue

  private void SfDataGrid2_QueryRowStyle(object sender, QueryRowStyleEventArgs e)
        {

            if (e.RowType == RowType.DefaultRow && e.RowIndex % 2 == 0)
                e.Style.BackColor = Color.WhiteSmoke;
            else
                e.Style.BackColor = SystemColors.Window;


            if (e.RowType == RowType.DefaultRow)
            {

                if (SfDataGridController.AreAllColumnsEmpty((e.RowData as DataRowView).Row))
                {
                
                    sfDataGrid2.View.Records.RemoveAt(e.RowIndex-3);
                }
            }


          
        }




AR Amal Raj U Syncfusion Team June 11, 2018 11:20 AM UTC

Hi Eren, 

Thanks for your update. 

if i press enter when adding new record it makes empty record 
By default, when pressing enter key with editing in AddNewRow cell, new row will be committed to the View with the default value from the underlying collection. Since DataTable has null default value, empty record is added to the view. This is the default behavior. 


some time if click add new row cell and typing it's trow exception from program.cs 
We have tried the maximum possibilities to reproduce the reported exception, but we could not reproduce the exception.  

On analyzing the provided screenshot, we suspect that you are using tooltip. 

The built-in tooltip support for SfDataGrid could not reproduce the reported exception. We suspect that you are customizing the built-in tooltip or showing the tooltip using SfToolTip component externally. 

So, could you please share us the customization or settings for tooltip if any or if using SfToolTip, please let us know the settings of showing the tooltip? Or let us know the replication of the exception clearly. 







To delete the empty row added                       
Instead of removing the empty record, you can prevent adding the empty record itself by validating the adding row in RowValidating event. Please refer to the below modified code example. 

Code Example: 
sfDataGrid.RowValidating += SfDataGrid_RowValidating; 
 
private void SfDataGrid_RowValidating(object sender, Syncfusion.WinForms.DataGrid.Events.RowValidatingEventArgs e) 
{ 
    var id = (e.DataRow.RowData as DataRowView).Row[0]; 
    var value = id != null ? id.ToString() : string.Empty; 
 
    if (string.IsNullOrEmpty(value)) 
    { 
        e.ErrorMessage = "Employee ID cannot be null"; 
        e.IsValid = false; 
    } 
} 
 

Sample Location: 
 
Regards, 
Amal Raj U. 



ER Eren June 11, 2018 01:29 PM UTC

Thank you for your support. I removed tooltip and it's solved. I appreciate that.


MA Mohanram Anbukkarasu Syncfusion Team June 12, 2018 06:12 AM UTC

Hi Eren,  
 
Thanks for your update. 
 
We are glad to know that the given solution has solved your query. Please let us know, If you need any further assistance. 
 
Regards, 
Mohanram A. 



MA Mohanram Anbukkarasu Syncfusion Team June 26, 2018 09:47 AM UTC

Hi Eren, 

We are glad to announce that our Essential Studio Volume 2, 2018 (Version 16.2.0.41) is rolled out and we have fixed the Null reference exception that occurs while setting DisplayText for the row header by using the DrawCell event in this release. It is available for download under the following link. 
 

We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance. 

Regards, 
Mohanram A. 



UN Unknown Syncfusion Team July 11, 2018 07:51 PM UTC

Same issue continues it's not solved with new release 


MA Mohanram Anbukkarasu Syncfusion Team July 12, 2018 11:22 AM UTC

Hi Eren, 

Thanks for your update. 

We have ensured that the reported issue is resolved in our latest version 16.2.0.41. Please find the image given below and sample from the given location. 

 
 

Code Snippet: 
void sfDataGrid_DrawCell(object sender, Syncfusion.WinForms.DataGrid.Events.DrawCellEventArgs e) 
{ 
    if (sfDataGrid.ShowRowHeader && e.RowIndex != 0) 
    { 
        if (e.ColumnIndex == 0) 
        { 
            e.DisplayText = e.RowIndex.ToString(); 
        } 
    } 
} 
 
 


We suspect that the assemblies referred in your project may be old assemblies. Please follow the below suggestions to resolve the issue if your application refer the older Syncfusion version, 

Suggestion 1: 
  • Uninstall all your old Essential Studio versions and install the latest Essential Studio version 16.2.0.41.
 
Suggestion 2: 
  • Open your project in Notepad.
  • Check whether any key tokens are referring for the Syncfusion dlls. If yes, remove that key tokens of all Syncfusion assemblies. Please refer to the below code example.

Code Example: 
 
<Reference Include="Syncfusion.SfDataGrid.WinForms, Version= 16.1400.0.37, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL"> 
 
<!--</Change the above code like as below>-->         
 
<Reference Include="Syncfusion.SfDataGrid.WinForms" /> 
 
Suggestion 3: 
  • Select all the Syncfusion assemblies from project reference and open the property window (Alt + Enter) for selected assemblies.
  • Change the specific version as false using property window.
  • Now, clean and rebuild your project.
 
 

After doing the above, if you are still facing the issue, please provide your issue reproducible project file. It will be helpful for us to provide the solution at the earliest.      

Regards, 
Mohanram A. 


Loader.
Up arrow icon