Author Topic: SetColumnCaptionList/SetColumnImage clears grid control  (Read 2519 times)

Jürg Menzi

  • Member
  • *
  • Posts: 25
SetColumnCaptionList/SetColumnImage clears grid control
« on: December 28, 2012, 08:54:44 AM »
Hi all

I've a problem with this both methods. If I change a header icon or text the grid will be cleared.
Is this a known 'feature' or did I miss something?

Thank you
Cheers

owenwengerd

  • Administrator
  • Hero Member
  • *****
  • Posts: 2636
    • Outside The Box
Re: SetColumnCaptionList/SetColumnImage clears grid control
« Reply #1 on: December 28, 2012, 01:30:37 PM »
I took a quick look at the code. It looks like there are some layout features of columns that cannot be changed after the column is created, so setting any of the column list properties is done by first deleting all columns, then recreating them. That results in cell values being cleared. It might be possible to save and restore cell values, but there would be some complexity in dealing with changes in the number of columns. Do you have a compelling case for settings column headers after the grid is populated?

Jürg Menzi

  • Member
  • *
  • Posts: 25
Re: SetColumnCaptionList/SetColumnImage clears grid control
« Reply #2 on: December 29, 2012, 03:12:04 AM »
Hi Owen
(...) Do you have a compelling case for settings column headers after the grid is populated?
Unfortunately yes:
I've tried to set a sort symbol by OnColumnClick event to the current column like ▼ or ▲. Used both ways by changing the caption list  to '▼ColTitle' or using the controls picture list.
Do you think there is a way to do this without rebuild the datagrid? The problem is, I've between 500 and 1000 rows to rebuilt and that's time-consuming.

Thank you
Cheers
Jürg

BTW, I used this a time ago successfully in VB's and VBA's grid controls without problems.
« Last Edit: December 29, 2012, 03:25:37 AM by Jürg Menzi »

owenwengerd

  • Administrator
  • Hero Member
  • *****
  • Posts: 2636
    • Outside The Box
Re: SetColumnCaptionList/SetColumnImage clears grid control
« Reply #3 on: December 29, 2012, 11:33:40 AM »
I've tried to set a sort symbol by OnColumnClick event to the current column like ▼ or ▲.

Ah, for that you should use SetColumnImage. Let me know if that works for you.

Jürg Menzi

  • Member
  • *
  • Posts: 25
Re: SetColumnCaptionList/SetColumnImage clears grid control
« Reply #4 on: January 02, 2013, 03:23:48 AM »
Hi Owen

As I wrote already, both methods SetColumnCaptionList and SetColumnImage clears the grid... :(

I wish you a happy new year!
Cheers
Jürg

owenwengerd

  • Administrator
  • Hero Member
  • *****
  • Posts: 2636
    • Outside The Box
Re: SetColumnCaptionList/SetColumnImage clears grid control
« Reply #5 on: January 02, 2013, 08:09:30 AM »
As I wrote already, both methods SetColumnCaptionList and SetColumnImage clears the grid... :(

Hmm, I assumed that you had mixed up SetColumnImage and SetColumnImageList, but I see now there is no SetColumnImageList. I looked at the code, and as best I can tell SetColumnImage should not reset the grid contents as it simply changes the image in the heder control. Please verify your previous results. If you are sure it does reset the grid contents, I will check it here under the debugger to find out why.

Jürg Menzi

  • Member
  • *
  • Posts: 25
Re: SetColumnCaptionList/SetColumnImage clears grid control
« Reply #6 on: January 03, 2013, 01:00:42 AM »
Hi Owen

You're right, the SetColumnImage method works without clearing the grid but, there is another reason why I've refused this method:
The icons waste - independend of size - an enormous space in the header (see pic). That looks not professional in an application. Is there a way to resize this space?

Cheers
Jürg


owenwengerd

  • Administrator
  • Hero Member
  • *****
  • Posts: 2636
    • Outside The Box
Re: SetColumnCaptionList/SetColumnImage clears grid control
« Reply #7 on: January 03, 2013, 07:22:49 AM »
When does the extra space get added? Does it increase each time you call SetColumnImage? I recall that the space does not get removed once it is shown, and that was one of the reasons for deleting and recreating columns at runtime, but I would not expect it to continue growing each time you change the image with another of the same size. If it does grow each time, I may need to investigate further.

Jürg Menzi

  • Member
  • *
  • Posts: 25
Re: SetColumnCaptionList/SetColumnImage clears grid control
« Reply #8 on: January 03, 2013, 07:56:25 AM »
Hi Owen

Thank you for your time.
My procedure is to set the ColumnImages at designtime to an empty (transparent) icon from the picture list of the control. At runtime I change the image index to the desired value. The used space is always the same but, he is also independent of the size of the icon 8x8, 16x16 or 32x32. After setting ColumnImage to an icon, the space never changes.

Cheers
Jürg

owenwengerd

  • Administrator
  • Hero Member
  • *****
  • Posts: 2636
    • Outside The Box
Re: SetColumnCaptionList/SetColumnImage clears grid control
« Reply #9 on: January 03, 2013, 07:32:41 PM »
I did some research, and I found that there is a function to set the icon margin. It looks like a margin of 1 pixel is the minimum practical. Even then, there is a 5 pixel (approximately) margin between the icon and the label, but it is much smaller than the default margin.

I could set the margin to 1 pixel for listview and grid controls. It seems unlikely, but I'm worried that someone may have relied on the larger default margin. I may try that in the alpha build and see if anybody complains.

Alternatively, you could use the text label suffix instead of an icon to denote sorting. For example, you could use a simple " v" or " ^" suffix, or get fancy and use "up" and "down" symbols.

Jürg Menzi

  • Member
  • *
  • Posts: 25
Re: SetColumnCaptionList/SetColumnImage clears grid control
« Reply #10 on: January 04, 2013, 01:59:54 AM »
Hi Owen

I did some research, and I found that there is a function to set the icon margin. It looks like a margin of 1 pixel is the minimum practical. Even then, there is a 5 pixel (approximately) margin between the icon and the label, but it is much smaller than the default margin.
I could set the margin to 1 pixel for listview and grid controls. It seems unlikely, but I'm worried that someone may have relied on the larger default margin. I may try that in the alpha build and see if anybody complains.
That would be a great option and I'm looking forward to this alpha build.

Alternatively, you could use the text label suffix instead of an icon to denote sorting. For example, you could use a simple " v" or " ^" suffix, or get fancy and use "up" and "down" symbols.
Hmm, do you mean to place a text label over the control to show the sorting symbols? But then I've to calculate all label positions on changing the column widths. Or is there something that I don't know ???

Again, thank you!
Cheers
Jürg
« Last Edit: January 04, 2013, 02:42:59 AM by Jürg Menzi »

owenwengerd

  • Administrator
  • Hero Member
  • *****
  • Posts: 2636
    • Outside The Box
Re: SetColumnCaptionList/SetColumnImage clears grid control
« Reply #11 on: January 04, 2013, 08:49:34 AM »
Hmm, do you mean to place a text label over the control to show the sorting symbols?

I was referring to the column caption.

Jürg Menzi

  • Member
  • *
  • Posts: 25
Re: SetColumnCaptionList/SetColumnImage clears grid control
« Reply #12 on: January 04, 2013, 09:30:14 AM »
Hi Owen

Probably I can't see the wood for the trees but, the only ColumnCaption access i know is by SetColumnCaptionList. And if I refreshing whose values, the grid is cleared. Is there something else to use?

Cheers
Jürg

owenwengerd

  • Administrator
  • Hero Member
  • *****
  • Posts: 2636
    • Outside The Box
Re: SetColumnCaptionList/SetColumnImage clears grid control
« Reply #13 on: January 04, 2013, 12:01:31 PM »
Sorry, I assumed there was a corresponding SetColumnCaption function, but I see there is not. This would be fairly easy to add, though, so I will put it on the to-do list.