Hello-
This post, even though it's old, suggests what I'd like to do should be possible:http://forums.infragistics.com/forums/p/5107/23272.aspx#23272
I've got an UltraGrid with two columns.
Column 0 is a UltraCombo loaded with a ValueList.Column 1 is a TextBox.
What I'd like to do is set the NullText property of column 1 whenever the value of column 0 changes.
Using that post above as a model, I've attached a new editor to the cell in column 1 as follows:
UltraTextEditor editor = new UltraTextEditor();((ISupportInitialize)editor).BeginInit();editor.NullText = "This is NullText";((ISupportInitialize)editor).EndInit();cell.EditorComponent = editor;
Unfortunately, "This is NullText" never displays even though the underlying value in column 1 is in fact null.
NOTE: "This is NullText" is just a test for this post. What I need to do eventually is assign editor.NullText a value that is associated with the value chosen from the dropdown in column 0.
First, although the above post SUGGESTS this is possible, is what I need to do possible?
If so, what have I done wrong with my code or how should this be handled differently?
Thank you.
For any of the followers of this thread still following it, I've gotten part of the way there with the following.
I set the CreationFilter propery of my grid a new instance of MyCreationFilter defined thusly:
private class MyCreationFilter : Infragistics.Win.IUIElementCreationFilter { public void AfterCreateChildElements(UIElement parent) { if (!(parent is CellUIElement)) { // Parent element is not a cell element return; }
// Get the associated column UltraGridColumn column = parent.GetContext(typeof(UltraGridColumn)) as UltraGridColumn; if ((column == null) || column.Key != "ColumnThatShouldHaveNullText") { // Not the column we care about return; }
// Set null text according to value of the combobox in Cell0 column.NullText = "Hello World"; // This is Cell1 }
public bool BeforeCreateChildElements(UIElement parent) { return false; } }
This works ONLY in the sense that the NullText property of the cell is set but there doesn't seem to be a way to set it per the selected value of the CombBox in Cell0 so it's mostly useless for what I need.
If anyone has any advice to finish this up, I'd appreciate the contribution but this is about as far as I am able to go with it.
There hasn't been any action on the support ticket so I'm pretty much stymied with this.
Best Regards
Mike- Thank you, I will give that a whirl. I've never done it so it might take me a bit to get there. Should I manage to come up with something particularly clever that actually works, I'll post it back here. There are 3 followers to this thread so it is interesting to more than just me I guess.
Stefaniya- Thank you, I'll watch the thread on the support ticket.
I appreciate everyone's time.
Hi,
I have created a support ticket for you with id: CAS-52042-K5S1P0. I will update you about the progress of this issue there.
Regards,
Stefaniya
Hi Robert,
I think you are on the right track here. But CellChange is probably not the best event to use. I think Brian mentioned it for the first option, but it doesn't really apply to his second suggestion of using a DefaultOwner. CellChange will only get fired if the user clicks into the cell and changes something. The event won't fire for any rows that were not modified by the user. So any rows that are in the DataSource initially, or any you add in code, will be wrong.
I'd use the InitializeRow event, instead. It will fire when the value of any cell in the row changes, as well as fire when the row is initially created, so it's perfect for what you need here.
I don't think this will currently work, though. Not every editor owner supports overriding every property using a DefaultOwner. If the grid already has a property for something that the editor normally handles, then the grid settings has to take precedence over the editor. Since the grid column already has a NullText property, it cannot look at the DefaultOwner.
But in fact, that's not true... the grid can look at the DefaultOwner provided that it knows whether or not it's own property was explicitly set. And in this case, I think it can know... but it's still not doing it.
This looks like a bug to me. So I'm going to forward this thread over to Infragistics Developer Support and have them write it up for developer review.
In the mean time, you could probably achieve what you want using a CreationFilter to set the Text of the TextUIElement in Cell 1.
Correct, the goal is to get a different NullText value in the Column1 cell depending on the selection of the dropdown in Column0.
I've revamped my assignment of the Column1 editor (which occurs in the Column0 CellChange event) to this:
// UltraGridCell cell = Column1 Cell for the current rowEditorWithText editor = new EditorWithText(new TestDefaultEditorOwner());cell.Editor = editor;
where TestDefaultEditorOwner is:class TestDefaultEditorOwner : Infragistics.Win.UltraWinEditors.DefaultEditorOwner{ public TestDefaultEditorOwner() : base() { }
public override bool GetNullText(object ownerContext, out string nullText) { return base.GetNullText(ownerContext, out nullText); }}
I think I interpreted your suggestion properly but unfortunately TestDefaultEditorOwner.GetNullText(...) is never hit (in the debugger) and so I'll not be able to actually change the nullText here and have it affect anything.
Did I follow your suggestion properly?
If not, where did I go wrong?
If so, what have I missed doing that prevents the override GetNullText(...) from being called?
Thank you for your time.