|
|
Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » How set read-only state to a editable column?
How set read-only state to a editable column? [message #5505] |
Thu, 28 September 2006 11:22 |
nicomesas
Messages: 104 Registered: September 2006 Location: Barcelona, Spain
|
Experienced Member |
|
|
Hi!
I have a ArrayCtrl with a list of data in which the two first entrances cannot be touched, are read-only. The other rows are read-write and can be removed.
Then, I can't know how to do this: to indicate to the ArrayCtrl that the two first rows are of read only.
the ArrayCtrl are defined :
....
theList.WhenEnterRow = THISBACK(TheListEnterRow);
...
theList.AddColumn(t_("data field")).Edit(editGrid) ;
...
...
Here we have the comented function WhenEnterRow.
void myDlg::TheListEnterRow()
{
int row = theList.GetCursor() ;
theList.Removing( row > 1 ) ; // do not remove the first 2 rows
// with this test screen is not beauty because I cant enter in the edit field but i can't modify it
editGrid.SetEditable(row > 1) ;
// this other test is not good, the row entirely is disabled
editGrid.Enable(row > 1) ;
//This example is not good either since function YesClickEdit I have written
// and in addition she only prevents the fact to publish when I do click.
// I continue being able to publish with Ctrl+Enter
if (row > 1)
theList.ColumnAt(1).YesClickEdit() ;
// in CtrlLib/ArrayCtrl.h I Added
// Column& YesClickEdit() { clickedit = true; return *this; }
else
theList.ColumnAt(1).NoClickEdit() ;
// With this other example the result is catastrophic. Everything works bad
if (row > 1)
theList.ColumnAt(1).Edit(editGrid) ;
else
theList.ColumnAt(1).NoEdit() ;
// In CtrlLib/ArrayCtrl.cpp I Added
//ArrayCtrl::Column& ArrayCtrl::Column::NoEdit()
//{
// if (edit) {
// arrayctrl->RemoveChild(edit) ;
// edit = NULL ;
// }
// return *this;
//}
}
I believe that the best thing would be to intercept the StartEdit function so that it recognizes a read-only column/row, that seems to you?
Nico
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: How set read-only state to a editable column? [message #5590 is a reply to message #5576] |
Wed, 04 October 2006 22:24 |
|
nicomesas wrote on Wed, 04 October 2006 06:08 | It is a complicated case, that I have been in the past but that it could return to happen.
I believe that the GridCtrl is looked more like which I am looking for, although I believe that there either a cell cannot be done read-only.
Nico
|
I can easily add it if you wish in next release...
Correct me if I'm wrong. You want to be able to do something like this:
grid.NoEditable(0)
grid.NoEditable(1)
what means that first 2 rows can't be edited even if columns have edits assigned, right?
|
|
|
Re: How set read-only state to a editable column? [message #5592 is a reply to message #5590] |
Thu, 05 October 2006 00:25 |
|
unodgs wrote on Wed, 04 October 2006 16:24 |
nicomesas wrote on Wed, 04 October 2006 06:08 | It is a complicated case, that I have been in the past but that it could return to happen.
I believe that the GridCtrl is looked more like which I am looking for, although I believe that there either a cell cannot be done read-only.
Nico
|
I can easily add it if you wish in next release...
Correct me if I'm wrong. You want to be able to do something like this:
grid.NoEditable(0)
grid.NoEditable(1)
what means that first 2 rows can't be edited even if columns have edits assigned, right?
|
I checked my code and it was there already... I only added NoEditable.
To make row not editable type:
grid.GetRow(0).NoEditable()
grid.GetRow(10).NoEditable()
or
grid.GetRow(0).Editable(false) in 0.95 version
|
|
|
|
Re: How set read-only state to a editable column? [message #5597 is a reply to message #5596] |
Thu, 05 October 2006 11:27 |
|
nicomesas wrote on Thu, 05 October 2006 04:30 |
unodgs wrote on Thu, 05 October 2006 00:25 |
I checked my code and it was there already... I only added NoEditable.
To make row not editable type:
grid.GetRow(0).NoEditable()
grid.GetRow(10).NoEditable()
or
grid.GetRow(0).Editable(false) in 0.95 version
|
This would be perfect!
Another desirable thing, would be to be able to establish a cell determined like NoEditable.
The perfect thing would be this
gridData.GetRow(4).GetCell(2).NoEditable();
//set column 2 in row 4 to be read-only.
But I intuit that he is too complex.
What I believe that would be more easy it is to wait to an event WhenRowChange to change the edition mode of that cell in the row.
void MyForm::WhenRowChange() {
int row = gridData.GetCursor();
gridData.GetColumn(2).Editable(row != 4);
}
I'm tested this piece of code and it and which does not work as I hoped, happens is that I can edit the column 2 in the row 4 without problems.
Nico
|
gridData.GetColumn(2).Editable(row != 4);
Both GetColumn and GetRow returns ItemRect& which has Editable method, but only in GetRow context it works.
I will add in 0.96 sth like this...
grid.GetCell(4, 2).Editable(true/false)
..that's not a problem.
New version will be released soon (maybe as a part of upp), but I can put it on dgs.pac.pl even sooner if you want.
I will also make Editable working in GetColumn context. If column will be read-only it coudn't be edited even if it has edit assigned.
|
|
|
|
Re: How set read-only state to a editable column? [message #5601 is a reply to message #5505] |
Thu, 05 October 2006 14:13 |
nicomesas
Messages: 104 Registered: September 2006 Location: Barcelona, Spain
|
Experienced Member |
|
|
Hey unodgs (Daniel?)
Still I am testing your wonderful GridCtrl and I have found a behavior quite rare.
Test it this small piece of code and you will see how the horizontal scrollbar does not work fine.
myGrid.Reset() ;
myGrid.Absolute() ;
String f = "NAME,EMAIL,tratamiento,cargo,dirección,codpostal,poblacion,provincia,pais,lengua,telefonos" ;
Vector<String> cols = Split( f, ',') ;
for (int i = 0; i < cols.GetCount(); i++)
{
myGrid.AddColumn(cols[i]).Width(150) ;
}
myGrid.AddRow(120) ;
Your you can solve the problem calling to
myGrid.AddColumns(col[i],150) ;
I believe that the Width function is failing, I believe we need to make a synchronization between the width total of the GridCtrl with the total of the sum of size of all the columns.
Nico
|
|
|
|
Re: How set read-only state to a editable column? [message #5604 is a reply to message #5598] |
Thu, 05 October 2006 15:13 |
|
nicomesas wrote on Thu, 05 October 2006 06:13 | I'm testing the code grid.GetRow(0).Editable(false) and I can edit the row 0!!
I have the last version of GridCtrl, downloaded from http://dgs.pac.pl/dgs.php?page=downloads
In summary... at this moment ...
grid.Editable(true/false) ; // I don't test it
grid.GetRow(xxx).Editable(true/false) ; // I test it but does not work, the row remains editable
grid.GetColumn(xxx).Editable(true/false) ; // I tested but you sais it is not implemented o functional?
|
Strange, at least it works in my latest dev version...
|
|
|
Goto Forum:
Current Time: Tue May 21 14:41:57 CEST 2024
Total time taken to generate the page: 0.01606 seconds
|
|
|