OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: Juerg W. Menzi on December 28, 2012, 07:54:44 AM

Title: SetColumnCaptionList/SetColumnImage clears grid control
Post by: Juerg W. Menzi on December 28, 2012, 07: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
Title: Re: SetColumnCaptionList/SetColumnImage clears grid control
Post by: owenwengerd on December 28, 2012, 12: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?
Title: Re: SetColumnCaptionList/SetColumnImage clears grid control
Post by: Juerg W. Menzi on December 29, 2012, 02:12:04 AM
Hi Owen
Quote from: owenwengerd on December 28, 2012, 12:30:37 PM
(...) 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.
Title: Re: SetColumnCaptionList/SetColumnImage clears grid control
Post by: owenwengerd on December 29, 2012, 10:33:40 AM
Quote from: Jürg Menzi on December 29, 2012, 02:12:04 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 (http://www.opendcl.com/HelpFiles/index.php?page=Reference/Method/Grid/SetColumnImage.htm). Let me know if that works for you.
Title: Re: SetColumnCaptionList/SetColumnImage clears grid control
Post by: Juerg W. Menzi on January 02, 2013, 02: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
Title: Re: SetColumnCaptionList/SetColumnImage clears grid control
Post by: owenwengerd on January 02, 2013, 07:09:30 AM
Quote from: Jürg Menzi on January 02, 2013, 02:23:48 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.
Title: Re: SetColumnCaptionList/SetColumnImage clears grid control
Post by: Juerg W. Menzi on January 03, 2013, 12: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

(http://i.imagebanana.com/img/lx5c5ph8/thumb/GridHeaderProblem.jpg) (http://www.imagebanana.com/view/lx5c5ph8/GridHeaderProblem.jpg)
Title: Re: SetColumnCaptionList/SetColumnImage clears grid control
Post by: owenwengerd on January 03, 2013, 06: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.
Title: Re: SetColumnCaptionList/SetColumnImage clears grid control
Post by: Juerg W. Menzi on January 03, 2013, 06: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
Title: Re: SetColumnCaptionList/SetColumnImage clears grid control
Post by: owenwengerd on January 03, 2013, 06: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.
Title: Re: SetColumnCaptionList/SetColumnImage clears grid control
Post by: Juerg W. Menzi on January 04, 2013, 12:59:54 AM
Hi Owen

Quote from: owenwengerd on January 03, 2013, 06: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.
That would be a great option and I'm looking forward to this alpha build.

Quote from: owenwengerd on January 03, 2013, 06:32:41 PM
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
Title: Re: SetColumnCaptionList/SetColumnImage clears grid control
Post by: owenwengerd on January 04, 2013, 07:49:34 AM
Quote from: Jürg Menzi on January 04, 2013, 12:59:54 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.
Title: Re: SetColumnCaptionList/SetColumnImage clears grid control
Post by: Juerg W. Menzi on January 04, 2013, 08: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
Title: Re: SetColumnCaptionList/SetColumnImage clears grid control
Post by: owenwengerd on January 04, 2013, 11:01:31 AM
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.