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,
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.
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?
Ok, I have to modify that statement. Getting SpanY = 2 worked just fine as long as I set SpanY = 1 on my new columns :) .
Thank you for your reply,
I was experimenting with OriginX a lot to get the desired effect. I managed to get the columns right most by setting the OriginX to a high value.. but I really desire the columns to be in the middle, not the far right. The way I did these settings before was by editing DisplayLayout (ie I was not working in the InitializeLayout method). Right now I'm experimenting with using InitializeLayout instead.. One problem with InitializeLayout for me is that it is called before I have the information I need to know what columns I need to add. If I set the datasource to null and then my source again, InitializeLayout is called, but it seems that my other settings (like what columns that are hidden) are reset. On other problem I have is that SpanY should be 2 on all columns except my unbound (I want the grid too like it usually does when you configure this in the designer). Even if I try to do this coding in the InitializeLayout I still can't get my other columns to have SpanY = 2.
Once OriginXResolved is set, is it possible to change its value again? Or are there a lot of constraints on what can be done when adding unbound columns?
Regards, 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.