Hello,
I have UltraWinGrid with one band and several columns. Now i search for a possibility to hide some columns if in the first column is a Special value (*).
How can I do this?
The Grid Show look like this:
Test1 Test2 Test3 Test4
* Only Text from column no4 now there is just one cell with this text
Test1 Test2 test3
Thanks
Hello Judith,
Thank you for posting in our forum.
If I understand you correctly what you need is when a particular cell contains some special value to span that cell over the next neighbor cell to the right. If this is what you need you can achieve such behavior by implementing the IUIElementCreationFilter interface. In your implementation you can set the cell’s UIElement width of the cell that contains special text as big as it is necessary to overlap the next cell. You can also set the width and height of the next cell to zero so it will not be visible. More about IUIElementCreationFilter you may find by following the next link http://help.infragistics.com/Help/Doc/WinForms/2015.1/CLR4.0/html/Infragistics4.Win.v15.1~Infragistics.Win.IUIElementCreationFilter.html.
In the attached sample solution I have implemented this approach. Please check my sample and let me know if this is what you are looking for of if I am missing something.
Thank you for using Infragistics Controls.
Thank you! This is the right direction. Thank you for the sample! I changed some things for me..but it worked. (I Need the case...cell 1 is * and then another cell gets bigger)
Ok, it worked..
BUT..if you take some more rows in the grid the performance is horrible!!! :-( Just take 40 rows in your sample and then write a * in a cell....
Do you know another way?
Sorry, after Insertion of several * the Performance is horrible. Not after the first, but aber 5-6
The Problem is: my grid has sometimes more than 2000 rows. Some users Change one row or Import with a button many rows.....
Thank you for your feedback.
I have optimized my CreationFilter. In the attached archive I am sending you modified version of my sample. Please let me know if you need any additional information.
Thank you so much.
But I have another Problem with it. I thought it would be easy then, but it is not.
What I really need, is: The value of column 1 is * and then the width of ANOTHER column is getting bigger an all other columns are hidden/removed. And another Problem the Column which is getting bigger is not the second. (Look at my script before)
The Thing is, i have a table an between the rows some rows should be comments and they are introduced in the key-Column with *. The column which can have more text is not the second...
In the BeforeCreateChildElements-Method i cannot use the second column.uielement to get the x-value...thats a Problem. How do i know where the column3 has to begin?
Table:Column1 Column2 Column3
Test1 Test2 Test3
* Here Comes a comment which is saved in Column3. So this cell should have the x of Column2.
Do you understand my Problem?
I'm so sorry about my bad english.............;-)
At the Moment I have something like this:
If cellElement IsNot Nothing Then
Dim cell As UltraGridCell = CType(cellElement.GetContext(GetType(UltraGridCell)), UltraGridCell)
If cell.Row.Cells("KEY").Value IsNot Nothing AndAlso cell.Row.Cells("KEY").Value.ToString = "*" Then
If cell.Column.Header.Caption = "COMMENT" Then
Dim w As Integer
w = cell.Row.GetUIElement.Rect.Width - cell.Row.Cells("KEY").Width
cell.GetUIElement.Rect = New Rectangle(cell.Row.Cells("KEY").GetUIElement.Rect.X + cell.Row.Cells("KEY").Width, _
cell.GetUIElement.Rect.Y, w, cellElement.Rect.Height)
ElseIf cell.Column.Header.Caption <> "KEY" And cell.Column.Header.Caption <> "COMMENT" Then
cellElement.Parent.ChildElements.Remove(cellElement)
End If
End if
Thank you so much!!!
This is exactly what I need. It works fine! :-))
Thank you for your help and samples. This forum is wonderful!!!!!
The slowest part in the Creation Filter was GetUIElement method. I have implemented the creation filter without this method. I have tested this by scrolling the grid in all direction, changing the cell texts, and resizing the form.
Please check this optimized solution and let me know if you face the same issue again.
Sorry, I have another question: Is it possible to cancel the painting? Or : Why is the Performance so horrible when about 10 rows with * are in the visible area? Do you have any ideas?
If not: Is it possible to split one datatable in two bands? so that i have the comments in the first band and the other rows in the second???
Ok, this is interesting.
I think the Performance is bad when more than about 8-10 rows (in the visible area) are * . Try your sample with "row mod 2 =0" and not 7. Or type in some rows a * ..after few rows the Performance gets very bad.
So sad!
Thank you so much. That is exactly what I Need.
Unfortunately the performance is bad. But just in my Project. I think the reason is because we have written so much Special Events like keydown, enteredit and so on which check the text of the columns...
I try to fix this... Hope I can do this.
Is it possible to decide in code when the cells are painted? I think the BeforeCreateChild-Method is to often busy
Thank you!