Currently, ColCount and Column.Count values of TStringGrid are independent, which leads to user errors and confusion.
It also necessitates many "C nil" checks throughout the TStringGrid code. I propose to implement auto-creation of TGridColimns upon every change of ColCount, which should eliminate both problems. Is it a good idea? Should I enter it into a tracker?
Mailing lists / lazarus / 2008-12
TStringGrid: ColCount vs Columns.Count
7 messages · 2 people · –
- JJesus Reyes 4
- AAlexander Klenin 3
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
--- El lun 8-dic-08, Alexander Klenin escribi?:
Show quoted text 17 lines
Indeed it worked that way when custom columns (cc) were implemented, what I didn't like is that it may "cancel" cc without notice, for example when at design time a set of cc are set up and this is why it currently enforce the use of cc to change counts.
But I don't really see a problem that colcount changes automatically the number of cc if there are some already, if there are no cc I think it should not add any, or what you think about it?
Jesus Reyes A.
?Todo sobre Amor y Sexo!
La gu?a completa para tu vida en Mujer de Hoy.
http://mx.mujer.yahoo.com/
Jesus Reyes wroteIndeed it worked that way when custom columns (cc) were implemented, what I didn't like is that it may "cancel" cc without notice, for example when at design time a set of cc are set up and this is why it currently enforce the use of cc to change counts. But I don't really see a problem that colcount changes automatically the number of cc if there are some already, if there are no cc I think it should not add any, or what you think about it?
The problem I ran into was as follows:
SGrid.ColCount := 2;
SGrid.Columns[1].Alignment := taCenter; // Oops!It is counter intuitive to me that the above code needs additional call to SGrid.Columns.Add
So, IMO the correct solution would be to _remove_ SGrid.Columns.Add totally and add/remove columns as needed when ColCount changes, thus leaving a single well-defined interface without the possibility of confusion.
However, this is not backwards-compatible... so, as a compromise, perhaps Columns.Add should increase ColCount to keep both in sync?
--- El mar 9-dic-08, Alexander Klenin escribi?:
Show quoted text 20 lines
[snip]
Show quoted text 5 lines
no they don't.
I think you wasn't too clear on what is what you wanted, anyway I think it has nothing wrong with having custom columns even for fixed cols, just it was not the initial goal.
Show quoted text 13 lines
Many if you think in the current situation and just changing SetColCount to get custom columns and columns on sync, but now I understand what you want, it would be nice indeed.
As I think it's not just changing a couple of lines, I would like to know what other persons think about this feature, would it be welcomed no not? if there is enough demand we can do it.
-- Alexander S. Klenin Insight Experts Ltd.
Jesus Reyes A.
?Todo sobre Amor y Sexo!
La gu?a completa para tu vida en Mujer de Hoy.
http://mx.mujer.yahoo.com/
> > what about fixed columns? should indices also count them? > Of course. Does not they now? no they don't.
Hm. So currently it is impossible to have, say, right-aligned text in fixed column?
I'd say it is a bug.
I think you wasn't too clear on what is what you wanted, anyway I think it has nothing wrong with having custom columns even for fixed cols, just it was not the initial goal.
Yes, I did not fully understand that my self at first ;-)
[snip]
Many if you think in the current situation and just changing SetColCount to get custom columns and columns on sync, but now I understand what you want, it would be nice indeed.
I agree.
--- El mar 9-dic-08, Alexander Klenin escribi?:
Show quoted text 10 lines
Using custom columns it is impossible because they were introduced by "back porting" dbgrid columns to standard grid, and you don't have a custom column for indicator column. So in my view it's not a bug but a feature :)
Of course you can have a right aligned fixed column, using OnPrepareCanvas just need to check when a fixed col is being "prepared" and set canvas.textstyle to the alignment you want. Yes it's not the same as with custom columns but at least it's not impossible :)
Jesus Reyes A.
?Todo sobre Amor y Sexo!
La gu?a completa para tu vida en Mujer de Hoy.
http://mx.mujer.yahoo.com/
--- El mar 9-dic-08, Alexander Klenin escribi?: [snip] no they don't. I think you wasn't…
--- El mar 9-dic-08, Jesus Reyes escribi?:
Show quoted text 6 lines
after that overwhelming demand (or the lack of it) I think we should try to make custom columns available by default, please submit a bug report asking for the feature I will be looking to implement it before 1.0.
Jesus Reyes A.
?Todo sobre Amor y Sexo!
La gu?a completa para tu vida en Mujer de Hoy.
http://mx.mujer.yahoo.com/
