I have an UltraGrid that has one column that may have a lot of data in it to display (but not edit). I set the CellActivation = Activation.ActivateOnly and VertScrollBar = true. This works fine. When the user clicks on a cell with a lot of data the vertical scroll bar appears as expected however the fomatting in the cell is lost. How can I retain the formatting while keeping the vertical scroll bar functionality. I tried to post a before and after screen shot but the site only allowed me to post 1 attachement so here is the after shot.
I am speculating because I don't see anything wrong with the formatting going by the screenshot...When you put a cell into edit mode a TextBox control is displayed therein, and the .NET TextBox does not support GDI+, where cells render this way by default. The result is a different number of characters per line which, if you were relying on the way they look when not in edit mode, would be different when in edit mode. If I misunderstood this please post the before/afer screenshots by zipping them and posting the .zip and we'll try to help.
Hi Brian,
Thanks for your reply and explanation. As you requested I am including before and after screen shots as an attached zip file for your review.
I am wondering if I am stuck with this behavior or is there a viable solution?
Thanks in advance
Omer
Hi Mike,
Sorry for the confusion but that was exactly the point I was trying to make...that using TextRendering did not make a difference.
To clear up the confusion let me try to restate my problem - I have a grid with a Notes column that may contain a lot more information than is visible on the screen initially (please see the attached BeforeEditNotesColumn.jpeg file). I would therefore like to have a vertical scroll bar.
From your previous posts you said that the way to do this is by setting the VertScrollBar = true for the column. However this will only work if the cell is in edit mode. Since I do not want the user to change the data I set CellActivation = Activation.ActivateOnly for that column. That produced the vertical scroll bar that I wanted but this time the formatting was off because the data coming from the DB contained a new line character that was used by a rich textbox in another part of the application. I was also able to fix this using your suggestion of using an EditorWithText and a datafilter to replace the new line character with "\r\n".
That helped but the text when it is in edit mode (please see the attached AfterEditNotesColumn.jpg file) is still rendered differenly from when it is NOT in edit mode. You can see these differences by comparing the attached 2 files. This is now the problem I am trying to solve and using the TextRenderingMode as you suggested did not help.
I hope this clears up any confusion. I am still hopeful that there will be a satisfactory resolution to this problem. Thanks for all of your help.
Kind regards
Hi,
Okay, so the screen shots you posted now clearly show a big difference in the formatting of the cell between when it is in edit mode from when it is out of edit mode. But if you are setting the TextRenderingMode to GDI and that is having no effect, then something else is going on there. There's a pretty clear and obvious difference between the two text rendering modes, and if you're not seeing any change, then either the setting is not being correctly applied or something else is going on here. I'm afraid I don't have any idea what that could be.
Are you sure that the TextRenderingMode is being set, and that you are setting it for the correct control, and that it's not getting re-set back to the original value somewhere in your code?
Are you using AppStyling? Maybe the Style Library you are using is overriding the property setting you are applying in code.
I am not using AppStyling. I used the TextRenderingMode for the grid as you suggested. I tried 2 different ways to implement it:
1. within a function called SetGridProperties -
ugNursingAssessment.DisplayLayout.Bands[0].Columns[
].Header.VisiblePosition = 4;
;
].Width = 370;
.ActivateOnly;
();
textEditor.DataFilter =
].Editor = textEditor;
ugNursingAssessment.UseAppStyling =
ugNursingAssessment.TextRenderingMode =
.GDI;
2. within an eventhandler ugNursingAssessment_BeforeCellActivate
private void ugNursingAssessment_BeforeCellActivate(object sender, CancelableCellEventArgs e)
{
TextRenderingMode.GDI;
}
else
TextRenderingMode.GDIPlus;
Neither method gave me the results I wanted. Any other ideas?
Thanks
if (e.Cell.Column.ToString() != "Notes")
Hi Omer,
When does the SetGridProperties method get called?
You don't want to set the TextRendering mode in an event of the grid like BeforeCellActivate. That certainly won't work. This is the kind of property that you should ideally be setting either at design-time or very early on in the initialization of your app, like in the form's Constructor immediately following the InitializeComponent call.
This particular grid gets refreshed every 30 seconds to display any data that might have changed. The SetGridProperties is called every time the grid is refreshed. So to answer your question; it is not called in the form's constructor.
I did however try your suggsetion:
public
NursingProgressNotesView()
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
and it didn't make a difference.
The solution in
http://ko.infragistics.com/community/forums/t/18063.aspx
helped me.
Sorry for the late reply. I tried your solution and it helped although it is still not 100%. However this may be good enough for our purposes. I also did NOT use the GDI TextRendering Mode. Thanks for all of your help.
There is now another issue that I was not aware of before and I will post that in a separate thread.
Thanks again
Okay, I see the issue now. It's a pretty subtle change. The first line of text is okay, but after that the text wrapping has to change due to the decreased available width of the cell.
CellActivation doesn't seem to make any difference here, it's just the VertScrollBar that does it.
There are basically two ways you could deal with this.
1) Make the scrollbar show all the time.
2) Leave a space in the cell where the scrollbar would be.
Personally, I think it will probably make the grid look pretty cluttered to have a scrollbar always display in every cell of the column. And in fact, the grid doesn't expose any way to do this in v8.3. If you had the latest version of the controls, you could use the new UltraControlContainerEditor to embed a TextBox into the cell and leave the scrollbar on all the time. But the UltraControlContainerEditor was not available in v8.3.
Leaving a space would have to be done using a CreationFilter and this could be done in v8.3.This is actually a pretty simple CreationFilter.
public class MyCreationFilter : IUIElementCreationFilter { #region IUIElementCreationFilter Members void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent) { if (parent is EditorWithTextUIElement) { UltraGridCell cell = parent.GetContext(typeof(UltraGridCell)) as UltraGridCell; if (cell != null && cell.Column.Key == "Column 0") { EditorWithTextDisplayTextUIElement editorWithTextDisplayTextUIElement = parent.GetDescendant(typeof(EditorWithTextDisplayTextUIElement)) as EditorWithTextDisplayTextUIElement; if (editorWithTextDisplayTextUIElement != null) { Rectangle rect = editorWithTextDisplayTextUIElement.Rect; editorWithTextDisplayTextUIElement.Rect = new Rectangle( rect.X, rect.Y, rect.Width - SystemInformation.VerticalScrollBarWidth, rect.Height); } } } } bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent) { return false; } #endregion }
Thanks for your prompt response. I got your app to run by altering the references. The 2 lines of code that you are missing in the ultraGrid1_InitializeLayout function are:
band.Columns[0].CellActivation =
Activation
band.Columns[0].VertScrollBar =
When you include these then the TextRenderingMode doesn't work as expected since the vertical scrollbar takes up some of the width of the cell. Since the dimensions of the cell change then I guess there is nothing that can be done to maintain the text formatting with and without a scrollbar. This is the issue at the heart of the problem.
omerk said: I can't compile your project becuase we do not have v9.2 of the Infragistics2 dlls. The latest version we have is v8.3. Would this make a difference? If not, could you please resend your project using the 8.3 version of these dlls instead?
You can just remove the 9.2 references from the project and add the equivalent 8.3 references.
I can't see any reason why an UltraTextEditor should cause any different in the behavior here. The column will use an EditorWithText by default, so it's essentially the same thing.