Hi,
I am having a different kind of requirement.
I have two lines of text in a single cell in Ultrawingrid.
I have to apply font size of 14 and color black to first line text.
And font size of 12 and color blue to second line text.
Could you please let me know how to do it?
Thanks,
Venkat.
Hi Mosam,
I'm still confused. Why are you using AutoSizeHeightOnly? That means that the label will only resize it's height and never it's width. Also, this property is obsolete and the same effect can be acheived another way as mentioned by the warning you can see in the application.
So are you thinking that you want the width of the column to be fixed and only the height of the rows will AutoSize to the contents? That's the only way that would make sense. But that's also going to make the preferred width of the UserControl ambiguous. So I'm having a a hard time wrapping my head around how that would work. I guess you could base the width on the OTHER labels and buttons and ignore width as far as the second label is concerned. But you have both labels set to AutoSizeHeightOnly, so that seems contradictory. That means there is no way to estabslihed the preferred Width. It's not clear to me what you want here. It sounds like what you want might not even be possible because there is a contradiction there. I recommend that you override GetPreferredSize on your UserControl and maybe play around with it and see how is works. Regarding the Image and/or buttons in the cells, you can't do that in InitializeRow when using UltraControlContainerEditor. The UltraControlContainerEditor essentially replaces the entire cell with a control. The grid will apply some Appearence property to your control like BackColor and ForeColor, because those are properties on Control. But it can't possible apply the Appearance.Image, and UltraControlContainerEditor doesn't suppose EditorButtons. If you want to change the button(s) that exist in the UserControl, then you would have to do that in the Value property setter and base that decision on something in the cell's value, just like I am doing with the Arrows image now. And the same applies to any other images.
Hi ,
One more observation - i would like to share with you.
In my original sample applicaiton - if you observe adding image to cell and button is written inside ultraGrid_InitializeRow() event where i am looping through row band columns one by one and will decide to add image and button based upon specific column/cell value. As per your sample POC - adding image and button logic is within setter of Value of CellInfoControl.cs so, can you pls let me know how i can shift that logic inside ultraGrid_InitializeRow() or any other way to do so.
Mosam
Hi Mike,
In earlier sample that I have posted is the same one which you have attached in your response and plus I have added code related to AutoSizeHeightOnly property through which label height get autosized which was not happening previously. Now, if you observe yellow highlighted cell values in screenshot Which is posted in my last reply, you will find that texts in label is not getting displayed fully as cell is not getting resized and texts within Label is so long that it requires cell resize as well I guess to display full text values within.
So, I need to resize usercontrol/ultra grid cell/labels accordingly so that it can displays full length of label value data which is there in last sample attached. Some of the cell is having values as below.
e.g. "888 aaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbb ccccccccccc eddddddddddddd 123457888\n(140011-24558667 %)"
So, here texts before \n should be added into first label and text after \n should be added into second label. Ultra grid cell should display such values properly.
I hope, it helps to understand the actual issue now.
Can you pls help here - if you can provide updated sample with the same.
I'm not sure I'm following you. In my sample, I had AutoSize on both labels set to true. But the size of the labels will not have any bearing on the size of the UserControl. They are two completely different things. The UserControl needs to be resizable, so that it will fit inside the grid cell. The grid will size the control to the cellas it paints each cell. So the code I added which re-positions the buttons in SetBoundsCore is needed so that the control itself responds properly to resizing. AutoSizing related to when the user double-clicks on the right edge of the column header. In that case, the grid will ask the editor (in this case the UltraControlContainerEditor) for the preferred size based on the value of the cell. The grid also asks the editor for the size of preferred size if you are using other AutoSize settings like AllowColSize or RowSizing settings that include "Auto" for the initial size of the column or row. The UltraControlContainerEditor, of course, has no idea how to do that since the contents of the cell are determined by a bunch of arbitrary controls inside the UserControl. So it's up to you to make that calculation and implement GetPreferredSize on your UserControl.The sample you posted here seems to be working in that regard. The columns appear to be coming up correctly sized - presumably the default implementation of UserControl is figuring out some kind of size based on the contained controls. But you can't AutoSize the columns or rows in your sample beyond that since your properrty settings don't allow the user to resize rows or columns. And you are not even overring GetPreferredSize on the UserControl.So I am not sure what you are asking.
I have tried to resize both labels using AutoSizeHeightOnly property and it gets auto resized as well. now it should resize cell also accordingly which is not happening. so, both label values are not getting displayed within grid cell.
Can you please update the attached sample for the same.
Thanks a lot for all your help.
8713.4643.SampleUltraGrid.zip