Hi, I have a ultraGridRowEditTemplate that is assigned to a wingrid band
e.g. ultraGridBand5.RowEditTemplate = this.ultraGridRowEditTemplate1;
However, once I hide or disable the wingrid and rebind it again via a ultracombo, I have lost the RowEditTemplate from the grid. Of course, exiting and then reloading the form will sort this (by firing the InitializeComponent() method), but I really don't want to have to do this. Is there anyway to assign the ultraGridRowEditTemplate back to the wingrid when the wingrid is shown again?ThanksChris
Hi,
There's no reason why hiding or disabling the grid should have any effect on the RowEditTemplate. I am assuming that you mean that you are hiding then showing the grid again. Obviously, the grid will never show the RowEditTemplate while the grid is disabled or invisible.
Setting the grid's DataSource will lose your entire layout, including the RowEditTemplate. The band will be destroyed and a new band created. So this is why it's a good idea to set the RowEditTemplate inside the InitializeLayout event so that it will get re-applied.
I'm not really sure what you are asking, though. Your question appears to be: how do you assign the RowEditTemplate back to the grid. But you already know how to do that - you posted the code right here. You set the RowEditTemplate propererty on the band.
grid.DisplayLayout.Bands[myBand].RowEditTemplate = this.ultraGridRowEditTemplate1;
Thank you Mike, I was obviously confused with the InitaliseComponent function doing the work for me on form load. Also regarding the RowEditTemplate object, is there a way I can format the text before it get painted into the UltraGridCellProxy object that is within the ultraGridRowEditTemplate?For example, The text appears left aligned in the wingrid cell, and when the user wants to edit the text of this cell, it appears middle aligned in the cell proxy? CheersChris
Hi Chris,
I can't think of any reason why the alignment should be different in the template than in the grid. Or different in the template when it's in edit mode as opposed to out of edit mode.
If you can post a small sample project demonstrating this behavior, I'd be happy to take a look at it and see what's going on. But I would think the solution would just be to set the column.CellAppearance.TextHAlign on the grid column.
Hi Mike, No worries about this question, I must have put it wrong, I was after if I can change the alignment of the text between the two, so there is no bug with the WinGrid library.Finally, Is there a way you can only open the RowEditTemplate dialog on only a cell or column double click. in the InitializeLayout method I havee.Layout.Bands[0].Override.RowEditTemplateUIType = RowEditTemplateUIType.OnDoubleClickRow;however, if I double click any cells in any of the row, it appears.
In code I am after something like...e.Layout.Bands[0].Columns[6].Override.RowEditTemplateUIType = RowEditTemplateUIType.OnDoubleClickRow;
Thanks
Chris
I'm a little confused by your question. You want the template to show only when you double click a cell or column and then you go on to say that it appears if you double click on any cell. Isn't that what you want?
Anyway, there's no RowEditTemplateUIType for that. But one thing you could do is turn the automatic display of the template off (RowEditTemplateUIType.None).
Then respond to the events of the grid, like the DoubleClickCell event and explicitly show the template:
e.Cell.Row.RowEditTemplateResolved.Show();
Sorry, I got the method wrong. The correct way to show the template is like this:
e.Cell.Row.ShowEditTemplate();
Hi Mike, Sorry for confusion, I want the RowEditTemplate to appear on a double click only on one column so...
if (e.Cell.Column.Key == "column name")
e.cell.Row.RowEditTemplateResolved.Show();
However, I have done what you have suggested, in the InitaliseLayout function, I have set the automatic display to be none
e.Layout.Bands[0].RowEditTemplate = this.ultraGridRowEditTemplate;
e.Layout.Bands[0].Override.RowEditTemplateUIType = RowEditTemplateUIType.None;And as you seen above, I have called the RowEditTemplateResolved.show() on the cell is double clicked event, however, When the RowEditTemplate appears, it has no text in the CellProxy object and when you click on OK or CANCEL, the dialogue doesn't close. Is there anything I have missed?ThanksChris