Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
nicomesas is currently offline  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 #5506 is a reply to message #5505] Thu, 28 September 2006 11:58 Go to previous messageGo to next message
nicomesas is currently offline  nicomesas
Messages: 104
Registered: September 2006
Location: Barcelona, Spain
Experienced Member
I believe that the best option is to establish two new functions in CtrlLib/ArrayCtrl.h
  bool editing:1 ; // Set to true in the constructor
  ArrayCtrl& Editing( bool b = true )                { editing = b; return *this ; }
  ArrayCtrl& NoEditing()                             { return Editing(false) ; }


and to modify the function in CtrlLib/ArrayCtrl.cpp of the following way
bool ArrayCtrl::IsEditing() const {
  if (editing) // line added
    for(int i = 0; i < column.GetCount(); i++)
      if(column[i].edit) return true;
  return false;
}


I'm testing this and work fine

Nico
Re: How set read-only state to a editable column? [message #5517 is a reply to message #5505] Fri, 29 September 2006 14:52 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
You are not required to provide editor for column. So perhaps just removing .Edit would work.

Anyway, if you want it to "look" edit, you can always set the editor to ReadOnly mode.,
Re: How set read-only state to a editable column? [message #5521 is a reply to message #5517] Fri, 29 September 2006 15:56 Go to previous messageGo to next message
nicomesas is currently offline  nicomesas
Messages: 104
Registered: September 2006
Location: Barcelona, Spain
Experienced Member
Quote:

You are not required to provide editor for column. So perhaps just removing .Edit would work.


I do not understand to you well. Can you write a pair of lines of code so that I cant understand you?

Quote:

Anyway, if you want it to "look" edit, you can always set the editor to ReadOnly mode.


This was my first idea, but although sige is read-only receiving the center and visually it is very ugly.

index.php?t=getfile&id=273&private=0

Nico
  • Attachment: read-only.png
    (Size: 9.76KB, Downloaded 2056 times)
Re: How set read-only state to a editable column? [message #5536 is a reply to message #5521] Sun, 01 October 2006 18:49 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
OK, but what would not be "visually ugly" here? I see this visual representation as the only possible one...
Re: How set read-only state to a editable column? [message #5544 is a reply to message #5536] Mon, 02 October 2006 10:10 Go to previous messageGo to next message
nicomesas is currently offline  nicomesas
Messages: 104
Registered: September 2006
Location: Barcelona, Spain
Experienced Member
What he would not be "ugly here", according to my to seem, is that the way edition cancelled when entering a line read-only.

What happens in fact is that in this example only there is an editable column. So that the effect that I look for is possible must have capacity to be able to edit each column individually and it seems to me that this is not possible with the ArrayCtrl, since when begins to publish, they appear all the columns in edit mode.

Recently (2 years ago) that I developed to a "gridControl" for another project GNU in Borland C++. I am going to try write an example and I will send it to you. I hope to be able today.

Nico
Re: How set read-only state to a editable column? [message #5548 is a reply to message #5544] Mon, 02 October 2006 12:01 Go to previous messageGo to next message
nicomesas is currently offline  nicomesas
Messages: 104
Registered: September 2006
Location: Barcelona, Spain
Experienced Member
There are a sample grid control with read only funcionality for a individual cell.

To view, unzip in a folder an execute. The column 'numeric' in the row 2 is read-only.

Nico
Re: How set read-only state to a editable column? [message #5563 is a reply to message #5548] Tue, 03 October 2006 15:06 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
nicomesas wrote on Mon, 02 October 2006 06:01

There are a sample grid control with read only funcionality for a individual cell.

To view, unzip in a folder an execute. The column 'numeric' in the row 2 is read-only.

Nico



Unfortunately, stops at starts with message "'01/10/2006' is not valid date!". Cannot get past it....

BTW, have you noticed Daniel's GridCtrl? It will soon become official U++ package, maybe that could help you. In fact, ArrayCtrl was not exactly meant as "grid"...

Mirek
Re: How set read-only state to a editable column? [message #5565 is a reply to message #5563] Tue, 03 October 2006 20:10 Go to previous messageGo to next message
nicomesas is currently offline  nicomesas
Messages: 104
Registered: September 2006
Location: Barcelona, Spain
Experienced Member
oooooh!
I'm sorry, the date is in spanish format (DD/MM/YYYY). I will modify the code and send to you.

GridCtrl? Yes, I will testing it now.

Thanks

Nico
Re: How set read-only state to a editable column? [message #5566 is a reply to message #5565] Tue, 03 October 2006 20:46 Go to previous messageGo to next message
nicomesas is currently offline  nicomesas
Messages: 104
Registered: September 2006
Location: Barcelona, Spain
Experienced Member
The project with that I have done this is old and it does not have location options, so easiest it has been to change the date to deceive to him.

If you want to prove it here you have it.

I believe that I am going to use GridCtrl

Thanks

Nico
Re: How set read-only state to a editable column? [message #5575 is a reply to message #5566] Wed, 04 October 2006 11:54 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I see, it looks like what you want is to disable editing for individual cell, right? OK, that is not possible with ArrayCtrl at the moment (only the column).
Re: How set read-only state to a editable column? [message #5576 is a reply to message #5575] Wed, 04 October 2006 12:08 Go to previous messageGo to next message
nicomesas is currently offline  nicomesas
Messages: 104
Registered: September 2006
Location: Barcelona, Spain
Experienced Member
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
Re: How set read-only state to a editable column? [message #5590 is a reply to message #5576] Wed, 04 October 2006 22:24 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

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 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

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 #5596 is a reply to message #5592] Thu, 05 October 2006 10:30 Go to previous messageGo to next message
nicomesas is currently offline  nicomesas
Messages: 104
Registered: September 2006
Location: Barcelona, Spain
Experienced Member
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! Smile

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. Confused

Nico
Re: How set read-only state to a editable column? [message #5597 is a reply to message #5596] Thu, 05 October 2006 11:27 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

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! Smile

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. Confused

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 #5598 is a reply to message #5597] Thu, 05 October 2006 12:13 Go to previous messageGo to next message
nicomesas is currently offline  nicomesas
Messages: 104
Registered: September 2006
Location: Barcelona, Spain
Experienced Member
I'm testing the code grid.GetRow(0).Editable(false) and I can edit the row 0!! Confused

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?

Nico




Re: How set read-only state to a editable column? [message #5601 is a reply to message #5505] Thu, 05 October 2006 14:13 Go to previous messageGo to next message
nicomesas is currently offline  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 #5603 is a reply to message #5601] Thu, 05 October 2006 15:10 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Change
myGrid.AddColumn(cols[i]).Width(150)

to
myGrid.AddColumn(cols[i], 150)


Width(150) is fixed in 0.96... (Frankly I never used Width Wink )

Thank you for testing! Keep finding bugs!
Re: How set read-only state to a editable column? [message #5604 is a reply to message #5598] Thu, 05 October 2006 15:13 Go to previous messageGo to previous message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

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!! Confused

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...
Previous Topic: first row strange behaviour
Next Topic: functions of HeaderCtrl [REQUEST?]
Goto Forum:
  


Current Time: Tue Apr 30 08:34:46 CEST 2024

Total time taken to generate the page: 0.03003 seconds