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.
I updated the sample with a couple of changes.
First, I enabled clicking the button.
Second, I noticed some weirdness with the positioning of the button and display of the arrows, so I fixed that in the user control. I also have to change the CellClickAction because you had it set to RowSelect and with that setting, the cell will never enter edit mode and so you will never be able to click the button. You might want to set CellClickAction on the columns that are not using the ControlContainer, but you can't really have both. Also, I hid a bunch of the columns that don't really work correct because the Value property isn't handling the case where the value of the cell doesn't have a line break in it. So you will need to update that to work in all cases. Regarding AutoSize, you will need to override GetPreferredSize on the UserControl and then figure out what the ideal size of the control will be. In this case, you can likely determine the width by adding the width of ultraLabel1 + ultraPictureBox1 + ultraButton1 and then presumably you will want to add some padding in there. And similarly, the height would be the height of ultraLabel1 and ultraLabel2 with some padding. But that's up to you. It's possible that the Width of those child controls is stale inside the GetPreferredSize method, so if you find that is the case, you might have to forced them to auto size by calling Update or Refresh, or do what I did in the SetBoundsCore and use PreferredSize instead of Size. Also, it looks like your grid is set to AutoFitStyle, so you can't resize the columns in this grid, anyway, so you will need to turn that off, if you want the user to be able to AutoSize.
4643.SampleUltraGrid.zip
Thanks Mike for sample. Can you pls further update the sample to have clickable button and also cell should be autosized based upon the content of the texts values within because it may have larger text value sometimes but can have small texts within in few cases. Image and button should display in top right corners.
I have gone through some of the samples like below but it seems diff than my actual requirement.
Embed Any Control within WinGrid Cell using ControlContainerEditor Object - Infragistics Windows Forms Help
Mosam Patel
Okay, I whipped up a sample to get you started with the ControlConainerEditor approach. It does make the code a lot simpler and cleaner, but it is by no means complete.
So the basic idea here is that I created a UserControl with 2 labels, a picturebox (for the arrows), and a button.
I hooked this up to the grid columns using ControlContainerEditor. When a grid cell paints, it sets the Value on the UserControl (which is called CellInfoControl) and the Value property on the control parses the string into the two labels.
Your original sample was using the cell index to determine whether or not to show the arrows, but you really can't do that here, and I'm sure you don't want to. That determination has to come from something in the value of the cell, so I used the top value here and parsed it into an int and then used odd or even, just to show give you an idea of what needs to be done.
It's worth nothing that since I specified only a RenderingControl on ControlContainerEditor, the cell will not allow editing, which means the user can't actually push the button. But that wasn't working in the sample as it already was, so I'm not sure if you need that or not. If you do need that, you will have to specify another instance of the UserControl as the EditingControl: this.controlContainerEditor.EditingControl = new CellInfoControl(); this.controlContainerEditor.EditingControlPropertyName = "Value"; this.controlContainerEditor.EnterEditModeMouseBehavior = EnterEditModeMouseBehavior.EnterEditModeAndClick;
And then handle the button click event on the UserControl using the grid's ActiveCell. Also, you might need to implement the Getter on the UserControl's Value property and re-build the string from the labels and such, reversing the parsing that is done in the Setter.
You might want to adjust the appearances and layout of the various controls inside the UserControl, and also maybe override GetPreferredSize so that auto-sizing works in the grid. But this should be enough to get you started.
8446.SampleUltraGrid.zip
Hi Mike,
Attaching sample application. Can you please help me out in below issues.
1. Is there any way if I want to show red arrow image on top right corner exactly before H button is getting displayed currently? Below red arrow image should be displayed exactly before H button.
2. Here, I used xml approach to display formatted text, image and button in same cell of ultra win grid. Can you please provide other alternative in which I don't need to convert cell values into xml for displaying formatted text, image and button in same cell.
I appreciate all your help so far.
Mosam
SampleUltraGrid.zip
Did you try pulling out the Value property of the cell and copying that into an UltraFormattedTextEditor? If that works and shows the image correctly, then the only other explanation is that the grid cell is not set up to use FormattedText. If you can post a small sample project here that I can run and Debug, I'd be happy to take a look at it for you. :)