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. Image for the cookie policy date
close icon

The text inserted in a cell disapear as soon as this cell lost the focus

Hia! I´m working with a syncfusion grid that originally was not created to be editable. Now I have changed de ReadOnly attribute to allow edit the content of the cells. The problem is that, actually i can edit the cells using the keyboard but when i click over other cell the inserted text dissapear. If I press tab or click in the form outside (in other words, when the grid lost the focus) the text keeps in the cell until i click again in the grid. Does anybody knows what´s wrong? There are more properties that should be modified in order to change the editable behaviour of the Syncfusion grid? Thank you in advance.

11 Replies

AD Administrator Syncfusion Team August 2, 2004 10:23 AM UTC

Are you using a GridDataBoundGrid or a GridControl? If it is the GridDataBoundGrid, is your DataSource (DataTable?) set to readonly somehow? If it is a GridControl, are you handling the SaveCellInfo event? Do you see any exceptions being listed in the output window when you do this? Can you post a sample project showing this problem?


JA jose acidrain August 2, 2004 12:12 PM UTC

>Are you using a GridDataBoundGrid or a GridControl? If it is the GridDataBoundGrid, is your DataSource (DataTable?) set to readonly somehow? If it is a GridControl, are you handling the SaveCellInfo event? > >Do you see any exceptions being listed in the output window when you do this? > >Can you post a sample project showing this problem? Thanks for being so quick! That´s right, I´m using a GridDataBoundGrid, but the DataSource don´t appears to be ReadOnly.(and the DataBindings collection is empty). Is there a different way to populate the grid with data "manually" when it has a DataSource asociated? By the other way, When i´m interacting with the grid there no any kind of error message. Simply the text dissapears. Instead of using a real Syncfusion grid, i´m working with a inherited one so by now is quite difficult send you any kind of example, sorry.


AD Administrator Syncfusion Team August 2, 2004 01:40 PM UTC

Without a sample showing the problem, I am not sure how much help I can be. Here is a sample that uses a derived grid that starts out ReadOnly and allows you to click a checkbox to make it not readonly. It seems to work OK. Does it work for you? What are you doing differently? GDBGSample_3148.zip What events are you handling and what overrides do you have? These may affect grid behavior? If you use the same DataSource with a WindowsForms datagrid, do the changes ''stick'' there? If you have our source code, you can do a debug build, place a stop in GridModelDataBinder.SaveCellInfo, and step through this code to see what is failing. If you can provide a sample project, we can try this here.


JA jose acidrain August 3, 2004 04:46 AM UTC

I have been debugging the SaveCellInfo method and the problem is related with the PropertyDescriptor because pd is null after this sentence (PropertyDescriptor pd = columnStyle.PropertyDescriptor;) and the updating of the value it is supposed to be done by this sentence: if (DirectSaveCellInfo) { object component = state.table[state.position]; pd.SetValue(component, e.Style.CellValue); . . . Anyway the stack of the process when i click in a differebt cell than the recent edited is always like this: Grid.GridDataBoundGrid.OnMouseDown Grid.GridInternal.GridSelectCellsMouseController.MouseDown Grid.GridCurrentCell.Deactivate(bool discardChanges = false) Grid.GridCellModelBase.ResetActiveText(int rowIndex = 3, int colIndex = 1) Grid.GridTextBoxCellRenderer.TextBoxChanged(System.Object sender = {Syncfusion.Windows.Forms.Grid.GridTextBoxControl}, System.EventArgs e = {System.EventArgs}) Why make a click in another cell fires a Deactivate->ResetActiveText? Sorry but the example is not working, i have found some compilation problems and the external references appears to be OK. Here are listed a couple of the messages showed just after the compilation: GDBGSample_3148\GDBGSample\Form1.cs(70): ''GDBGSample.MyGridDataBoundGrid'' does not contains a definition for ''OptimizeInsertRemoveCells'' GDBGSample_3148\GDBGSample\GDBGSample_VB\Form1.vb(58): ''ShowTreeLines'' is not a member of ''GDBGSample.MyGridDataBoundGrid''. Maybe this info allow you to help me to solve the problem, but if anyway you need more info i can start to work in a example to send you, because there are some methods overriden.


AD Administrator Syncfusion Team August 3, 2004 06:13 AM UTC

Are you setting DirectSaveCellInfo = true somewhere in your code? The gridDataBoundGrid only uses this property while copying/pasting/deleting cell ranges, and does not use it when you type into a cell. Normally, this value needs to be false (its default value). So, you might try to spot why that property is true in your code. As far as the syntax errors from the sample, you can just comment out those lines to get things to run. They suggest you are using a 1.6 version of our libraries and not a 2.x version.


JA jose acidrain August 3, 2004 07:49 AM UTC

The DirectSaveCellInfo property has the right value (false). The difference between the behaviour of your example and my grid is the pd variable inside the SaveCellInfo method, because in your example this variable has a value and in my one is just null. I mean, in that method the sentence: columnStyle.PropertyDescriptor returns null debbuging my code so the later sentence: pd.SetValue(component, columnStyle.value) is not executed ´cos the condition (pd != null) is checked to avoid the nullReferenceException. Do i need to initialice any property previously to access to the value of columnStyle.PropertyDescriptor? What can mean that property has a null vaue? PD: The sample is now running properly. >Are you setting DirectSaveCellInfo = true somewhere in your code? > >The gridDataBoundGrid only uses this property while copying/pasting/deleting cell ranges, and does not use it when you type into a cell. Normally, this value needs to be false (its default value). > >So, you might try to spot why that property is true in your code. > >As far as the syntax errors from the sample, you can just comment out those lines to get things to run. They suggest you are using a 1.6 version of our libraries and not a 2.x version.


AD Administrator Syncfusion Team August 3, 2004 08:19 AM UTC

The property descriptors should be initialized when you set the DataSource to the grid. Now if you set GridBoundColumns AFTER you set the datasource property for the grid, the proper property descriptors may not have been set. So, after setting GridBoundCoulmns, you might try calling grid.Binder,InitializeColumns to see if that takes care of this problem. Are you using the latest public release, 2.0.5.1?


JA jose acidrain August 4, 2004 07:43 AM UTC

We are using the 1.6.1.0 version, but by now we prefer (if it´s possible) keep that version in order to keep our inherited grid stable. In the attached excel sheet you can find two examples of the object {Syncfusion.Windows.Forms.Grid.GridBoundColumn} in the process of the debugging of the two examples (yours one and our not editable example). The main difference between them is that in our example the MappingName and PropertyDescriptor are empty (null) and in your one that properties have value. The execution of both cases runs follows the same path until that line of code: if (this.gridColumns.Count == 0) { _InitializeColumns(internalGridColumns, pdc); binder.SynchronizeColCount(); } else { this.itemProperties = pdc; int count = this.gridColumns.Count; . . . in Syncfusion.Windows.Forms.Grid.GridHierarchyLevel._InitializeColumns(System.Object table = {System.Data.DataView}, System.ComponentModel.PropertyDescriptorCollection pdc = {System.ComponentModel.PropertyDescriptorCollection}) Line 3924 C# In our case, the if evaluates to false so the ''else'' path is executed. In your example, the if evaluates to true Comparing the 2 objects_6313.zip


AD Administrator Syncfusion Team August 4, 2004 10:39 AM UTC

I am sorry, but nothing occurred to me as I looked at your spredsheet. Without a sample, I do not know how to be of much help. I would suggest you try 2.0.5.1. It has many improvements over 1.6.0 with respect to being more flexible in how the databinding works. One thing that can lead to null property descriptors are empty lists. Normally this shows up in hiearchical data when you start out with an empty child list. Are you using such data? In such cases, the grid needs to be able to query an object in the list to get the properties necessary to set the propertyDescriptors. If there are no objects in the list, then the grid goes through some hoops trying to find out what the properties are. In 2.0.5.1, this includes checking whether the empty list implements ITypedList. In some cases, it also uses calls an empty contructor with hopes that that will return an object it can query. This alternate querying process has matured since 1.6.0, and is much better in finding a proper object to query for descriptors. Is it possible that you are running into this kind of situation? Are you using hierarchical data or have empty lists?


AD Administrator Syncfusion Team August 4, 2004 10:43 AM UTC

This thread had a problem where teh BindContext was not being set. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=17226 Is you grid on a panel or recordnavcontrol or some other container. If so, you might want to set all teh BindingContext involved to the same one, something like this.grid.BindingContext = this.BindingContext; this.panel1.BindingContext = this.BindingContext; This is just something to try, I do not know whether it will affect teh problem you are seeing or not.


JA jose acidrain August 5, 2004 10:37 AM UTC

Thank you very much for the support Clay. The problem is solved. The cause of the problem was a wrong mapping between the grid a the DataSource.

Loader.
Live Chat Icon For mobile
Up arrow icon