Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
257 views
in Technique[技术] by (71.8m points)

c# - Moving the column of RenderTable

I have a renderTable and I am adding rows and columns to the table as follows-

RenderTable renderTable = new RenderTable(); 
DataTable dt = GetData(); 
foreach (DataRow row in dt.Rows)        
{ 
      var header = renderTable.Rows[renderTable.Rows.Count]; 
      header[0].Text = "Column 1"; 
      header[1].Text = "Column 2"; 
      header[2].Text = "Column 3"; 
      header[1].Text = "Column 4"; 

      var data = renderTable.Rows[renderTable.Rows.Count];
      data [0].Text = row["col1"].ToString(); // 10
      data [1].Text = row["col2"].ToString(); // 11
      data [2].Text = row["col3"].ToString(); // 12
      data [3].Text = row["col4"].ToString(); // 13
}

This is working fine and table is rendering as folllows-

Column 1    Column2   Column3    Column4
  10           11        12         13

My requirement is, now I want to move the column 4 to another place like 2nd place as follows . (this place can differ depending on condition)

Column 1    Column4   Column2    Column3
  10           13        11         12

I tried Insert method but it is not working for me as the insert index may change. Is there any function of render table to move the column to specified index.

Please suggest any alternative if any.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

We regret to mention but there isn't any function that can allow the moving of column of RenderTable to a specified index since the Cols of C1PrintDocument is ReadOnly.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...