Hi, I'm a beginner in ultragrid. (sorry, I'm poor at English)
I've referred below two links.
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.Aspx?ArticleID=1977
http://forums.infragistics.com/forums/p/2834/16564.aspx
Some parts of columns are painted well, but the others are not.
I think assignment of position value was processed exactly and I confirmed that values with run time debugger.
I want to know the limitation of Header.Visibleposition to work properly.
I used a column's hidden property, does this property make a problem?
Here's my code.
int i, colCount, rowCount, j;
bool[] bHidden;
stIndexValue nHeaderVisiblePositions;
long total = 0;
const string comments = "입금통장인자내용";
string[] sTgtColKeys = {"jeogyong_cd2", "yegeumju", "gyejwa_no", "dr_amt", comments};
string[] sTgtHeaders = {"은행코드", "예금주성명", "입금계좌번호", "이체금액", comments};
string[] sSrcHeaders = {"적용코드2", "예금주", "계좌번호", "입금액", comments};
DataTable dt;
DataRow dw;
ArrayList ar;
rowCount = ugdList.Rows.Count;
if (rowCount < 1)
return;
// allocate array variables for back up
colCount = ugdList.DisplayLayout.Bands[0].Columns.Count;
bHidden = new Boolean[colCount];
ar = new ArrayList(colCount);
// back up hidden, ordinal property and force all column hidden
for (i = 0; i < colCount; i++)
{
bHidden[i] = ugdList.DisplayLayout.Bands[0].Columns[i].Hidden;
nHeaderVisiblePositions.idx = i;
nHeaderVisiblePositions.val = ugdList.DisplayLayout.Bands[0].Columns[i].Header.VisiblePosition;
ar.Add(nHeaderVisiblePositions);
ugdList.DisplayLayout.Bands[0].Columns[i].Hidden = true;
}
// set up valid column
for (i = 0; i < sTgtColKeys.Length; i++)
ugdList.DisplayLayout.Bands[0].Columns[sTgtColKeys[i]].Hidden = false;
ugdList.DisplayLayout.Bands[0].Columns[sTgtColKeys[i]].Header.Caption = sTgtHeaders[i];
ugdList.DisplayLayout.Bands[0].Columns[sTgtColKeys[i]].Header.VisiblePosition = i;
j = sTgtColKeys.Length;
if (ugdList.DisplayLayout.Bands[0].Columns[i].Hidden)
ugdList.DisplayLayout.Bands[0].Columns[i].Header.VisiblePosition = j++;
// export to excel
this.UltraGridToExcel(this.ugdList);
// restore the header captions
ugdList.DisplayLayout.Bands[0].Columns[sTgtColKeys[i]].Header.Caption = sSrcHeaders[i];
// restore hidden, ordinal property
ar.Sort(new IndexValueComparer());
ugdList.DisplayLayout.Bands[0].Columns[i].Hidden = bHidden[i];
ugdList.DisplayLayout.Bands[0].Columns[((stIndexValue)ar[i]).idx].Header.VisiblePosition = ((stIndexValue)ar[i]).val;
...
=========================================================================
Thanks in advance
Hi,
It's really hard to tell much from a code snippet like this. I don't see anything obviously wrong with it, but it's pretty complex and with variable names like "i" and "j", it's pretty tough to read.
What exactly are you trying to acheive? And what is not working? Perhaps you could post a small sample project demonstrating the issue?
I also have some problems with VisiblePosition property. I have a UltraGrid. It is binded with a data through DataSource.
After a data is loaded from DataSource, I am trying to rearrange the columns order by this way:
layout.Bands[0].Columns[colName].Header.VisiblePosition = pos;
I do the same for half of the columns. But they are not appear on the positions that I set up.
May be the problem is that I do not set VisiblePosition property for all columns in the Band? Or may be there are some other conditions should be satisfied?
I also set property: grid.DisplayLayout.Override.AllowColMoving = AllowColMoving.WithinBand; But I think it is intended to be used for user to allow him to move columns and is not suitable for my situation.
Thank you!
Should it work if positions are not set in a not normal order 0 4 5 6 2 3 1 ?
You appear to have posted this same question several times. I answered it here:
Change the order of columns in Ultragrid - NetAdvantage for Windows Forms - WinGrid