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

Static CellType

Hi...
I'm trying to forbid the user from writing stuff in the cell, but I want him to still be able to select it by double clicking... but it seems if I make cell a "static" it doesn't raise the double click event any more. And if I set the ReadOnly property to true it can still be written in it. How can I solve this problem? please help :)

9 Replies

AD Administrator Syncfusion Team March 21, 2007 05:35 PM UTC

Hi Vicko,

Please try to provide us some more information on this issue. I tried to reproduce the issue, but couldn't. kindly provide us a small sample to reproduce the issue or modify this sample accordingly. This will help us to analyse the issue further.

///////
///Or
///////

If you want to cancel the editing of the cell then handle the CurrentCellKeyPress event of the grid and set e.Handled property to true;. Here is a code snippet.

this.gridControl1.CurrentCellKeyPress +=new KeyPressEventHandler(gridControl1_CurrentCellKeyPress);

Best regards,
Haneef


VH Vicko Hazdovac March 23, 2007 06:25 AM UTC

Me again :)
I've posted this message already, but it seems something went wrong....
Anyways - I've attached my own file to show you where the problem is. It's very simplified example of a project I'm working on (because the original project is huge). I am aware of the fact that I didn't choose the most elegant solution for controlling the grid, but I think it is the only one because of the nature of the project.
If you have any idea on how better to do the thing I'm trying to do in this file, I'll be more than glad to try it out.
Well, that's it for now. Thanks in advance.
(oh, and by the way, I'm using Essential Tools version 4.4.0.51)

Test_DoubleClick.zip


VH Vicko Hazdovac March 27, 2007 05:35 AM UTC

ehm... 'scuse me
I was wandering if there is anything you can tell me about the problem. It's rather important issue. Please reply as soon as possible so would know what to expect (or when to expect a solution).


JS Jeba S Syncfusion Team March 27, 2007 06:38 AM UTC

Hi Vicko,

Please set the AllowEdit property to false to prevent the user from writing.

this.gridGroupingControl1.TableDescriptor.AllowEdit = false;


Kindly let us know if this helps.

Best Regards,
Jeba.


VH Vicko Hazdovac March 28, 2007 05:32 AM UTC

Well it kinda helped but it also didn't :)
The thing is - it got double click to work just fine, but since the AlllowEdit is now false - entire table is frozen. I want to be able to insert new records. I've set the AddNew property to true but with no effect...


JS Jeba S Syncfusion Team March 28, 2007 07:41 AM UTC

Hi Vicko,

To do it for particular rows, you would either add a ConditionalFormat or handle QueryCellStyleInfo:

1) You can use GridGroupingControl.QueryCellStyleInfo and provide the style setting on demand there. This is useful when you want to use a particular style setting for some arbitary row in the grouping grid. There is a sample at the bottom of this forum thread.

http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=11530

2) If you want to set read-only property for a row, then you can add a conditional format to the grid.TableDescriptor.ConditionaFormats collection. You can see this discussed with a sample in this forum thread.

http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=11621

Kindly let us know if you need more information.

Best Regards,
Jeba.


VH Vicko Hazdovac March 29, 2007 10:49 AM UTC

Unfortunately none of these do me any good.
Here's the thing :
I'm using GridColumnDescriptor class in the following way:

GridcolumnDescriptor gdc = new GridcolumnDescriptor(title);
gdc.Appearance.AnyRecordFieldCell.CellType = "Static";
//or gdc.Appearance.AnyRecordFieldCell.CellType = "ReadOnly";

gdc.AddNewRecordFieldCell.CellType = "TextBox";
GridGroupingControl1.Tabledecriptor.Columns.Add(gdc);

After that the double click just won't work, and I really, really need it to.

I even tried with the QueryCellStyleInfo event
( with e.Style.ReadOnly set to true; )
and it still does the same thing (read-only cells do not trigger double click)

All of the threads that I've read mostly deal with the color and format of the text. None of them mention the read-only or static properties of the cell.
There must be a way to make read only cell clickable.


HA haneefm Syncfusion Team March 29, 2007 08:12 PM UTC

Hi Vicko,

One comment is that CurrentCellControlDoubleClick gets fired on an editing cell control in a grid(it does not fire when you click non editing cell control). If you need to catch the double clicks on non editing cell(Static ,Header or etc), you can use TableControlCellDoubleClick.

private void gridGroupingControl1_TableControlCellDoubleClick(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellClickEventArgs e)
{
MessageBox.Show("Double Click Fired");
}

Here is a modified sample.
Test_DoubleClick.zip

Best regards,
Haneef


VH Vicko Hazdovac March 30, 2007 05:50 AM UTC

I've solved the problem using the TableControlCurrentCellChanging() event

void GridGroupingControl1_TableControlCurrentCellChanging(object sender, GridTableControlCancelEventArgs e)
{
if ( this.Table.CurrentElement != null && this.Table.CurrentElement.Kind == DisplayElementKind.Record)
{
if (e.TableControl.CurrentCell.IsEditing == true)
e.Inner.Cancel = true;
}
}

this way when the user tries to add new text into a cell, it cancels his input automatically.

thank you for your help anyway
Vice

Loader.
Live Chat Icon For mobile
Up arrow icon