Hello,
I'm using an UltraWinGrid. Depending on my indata I wish to add a number of unbound boolean columns. I want to group these columnheaders together using the grouping feature that was added in 9.1. My problem is that when I add these columns (and their common group) the group is hidden behind my databound columns. I'm guessing that this has something to do with RowLayoutGroupInfo and OriginX, OriginY. But after modifying the code in a number of ways, I still can't figure out how to make my new group not get hidden behind the already existing columns.
Is there any good tutorial on setting up this kind of "on the fly" scheme in a WinGrid with unbound columns?
Chers, Johan
Hi Johan,
Are you setting the OriginX and OriginY of the new group? I think if you don't set it at all, then the default values are -1 and this means it will place the grid at the right-hand side of the layout. Or maybe it's -2 that will do that.
If those don't work, then what you need to do is take a look at the groups or columns that you have currently display and look at the OriginXResolved and SpanX of each one. You only have to worry about the top-level ones. For example, if you have columns inside a group, then you can ignore those. You only need to be concerned with groups and columns that are at the root level and are not contained inside another group.
Then you just have to find the highest OriginXResolved+SpanX to find out the coordinates of the last logical column in the layout and you can set SpanX on the new group to that value so it's at the end.
Perhaps it would help if I made my case a bit more concrete..
I use the following code:
foreach (SubscriptionRow edition in m_EditionSubscriptions)
{
e.Layout.Bands[0].Columns.Add(edition.Name);
/* Some intialization of the new column */
}
if (m_EditionSubscriptions.Count > 0)
UltraGridGroup group = e.Layout.Bands[0].Groups.Add("Editions", "Editions");
e.Layout.Bands[0].Columns[edition.Name].RowLayoutColumnInfo.ParentGroup = group;
} group.RowLayoutGroupInfo.OriginX = 5;
int numberOfEditions = m_EditionSubscriptions.Count;
int i = 1;
//Sets all the origins.
e.Layout.Bands[0].Columns["Name"].RowLayoutColumnInfo.OriginX = 1;
e.Layout.Bands[0].Columns["Price"].RowLayoutColumnInfo.OriginX = 2;
e.Layout.Bands[0].Columns["BuyTrial"].RowLayoutColumnInfo.OriginX = 3;
e.Layout.Bands[0].Columns["BuySubscription"].RowLayoutColumnInfo.OriginX = 4;
e.Layout.Bands[0].Columns[edition.Name].RowLayoutColumnInfo.OriginX = 4 + i;
i++;
e.Layout.Bands[0].Columns["IsRecurring"].RowLayoutColumnInfo.OriginX = 5 + numberOfEditions;
e.Layout.Bands[0].Columns["Expires"].RowLayoutColumnInfo.OriginX = 6 + numberOfEditions;
As you can see in the code I have a number of already existing column (Name, Price, Currency etc.). I want to place my new columns in originx = 5. And then I set the origin of the columns that comes after. This code is situated in InitializeLayout. What happens when I use this code is the following:
What can be done about this?
Hi,
It's really hard to work with a code snippet like this, since I can't run it or see what the layout is at run-time. But it looks to me like the OriginX here is fine. The Standard and Professional columns show up on the right side of the grid, just where you want them. The problem here appears to be the OriginY, which you are not setting. You probably need to set it to 0 for "Standard" and 1 or 2 for "Professional".
Also... it looks like the SpanX for the two columns are different, since they are not lining up on the right edge.