Hello again!
In my application, I have a radGridView control binded to database. I present production summary in it and I want to have there two progressbar columns in it. I follow the article about creating custom cell elements in CellFormat event. And everything works fine until I need to scroll data. Progressbar remain in their places and dodn't scroll with rest of the data. They seems to be over the row.
The problem is similar to this: http://www.telerik.com/community/forums/winforms/gridview/controls-are-moving-between-rows.aspx and this http://www.telerik.com/community/forums/winforms/gridview/radgridview-custom-elements-and-sorting.aspx.
But none of these solution seems to work. This is the problem causing part of my code:
1. Setting the columns from database, and adding two new columns for progress bars.
2. Cell formatiing event for first progress bar.
Some elements are only because the " ill " demodata in database, but it isn't important. in the if case I try to use the one of the solution but it doesn't work or I don't understand it.
I do no enable editing, adding etc in the grid. It is only for presenting and sorting data. And the scrollinup or scrolling with handling the scrollbar by cursor made mentioned above problem.
I will be greatfull for fast reply with working solution :)
In my application, I have a radGridView control binded to database. I present production summary in it and I want to have there two progressbar columns in it. I follow the article about creating custom cell elements in CellFormat event. And everything works fine until I need to scroll data. Progressbar remain in their places and dodn't scroll with rest of the data. They seems to be over the row.
The problem is similar to this: http://www.telerik.com/community/forums/winforms/gridview/controls-are-moving-between-rows.aspx and this http://www.telerik.com/community/forums/winforms/gridview/radgridview-custom-elements-and-sorting.aspx.
But none of these solution seems to work. This is the problem causing part of my code:
1. Setting the columns from database, and adding two new columns for progress bars.
| private void SetMainGridColumns() |
| { |
| for (int i = 0; i < this.radGridViewProductionList.Columns.Count; i++) |
| { |
| this.radGridViewProductionList.Columns[i].IsVisible = false; |
| } |
| this.radGridViewProductionList.Columns["number"].IsVisible = true; |
| this.radGridViewProductionList.Columns["number"].HeaderText = "Nr zamówienia"; |
| this.radGridViewProductionList.Columns["numberCard"].IsVisible = true; |
| this.radGridViewProductionList.Columns["numberCard"].HeaderText = "Nr karty"; |
| this.radGridViewProductionList.Columns["ItemsFactoryCard"].IsVisible = true; |
| this.radGridViewProductionList.Columns["ItemsFactoryCard"].HeaderText = "Produkt"; |
| this.radGridViewProductionList.Columns["datePlannedRealisation"].IsVisible = true; |
| this.radGridViewProductionList.Columns["datePlannedRealisation"].HeaderText = "Termin realizacji"; |
| this.radGridViewProductionList.Columns.Add(new GridViewDataColumn(){UniqueName = "TimeRemaining", HeaderText = "Pozostało dni"}); |
| this.radGridViewProductionList.Columns.Add(new GridViewDataColumn(){UniqueName = "Progres", HeaderText = "Postęp"}); |
| this.radGridViewProductionList.MasterGridViewTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; |
| } |
2. Cell formatiing event for first progress bar.
| private void radGridViewProductionList_CellFormatting(object sender, CellFormattingEventArgs e) |
| { |
| // exclude header element in the data column |
| if (e.CellElement.ColumnInfo is GridViewDataColumn)// && !(e.CellElement.RowElement is GridHeaderRowElement)) |
| { |
| GridViewDataColumn column = (GridViewDataColumn)e.CellElement.ColumnInfo; |
| if (column.UniqueName == "TimeRemaining") |
| { |
| // check if the progress bar is already added to the cell |
| RadProgressBarElement element; |
| if (e.CellElement.Children.Count > 0) |
| { |
| //element = (RadProgressBarElement)e.CellElement.Children[0]; |
| //this.SetValuesToElement(e.CellElement, element); |
| return; |
| } |
| element = new RadProgressBarElement(); |
| //int days = ((DateTime)e.CellElement.RowInfo.Cells["datePlannedRealisation"].Value - DateTime.Today).Days; |
| int days = new Random().Next(0, 100); //tymczasowo, bo dane w bazie fikcyjne i wychodza glupoty |
| element.Text = days + " dni"; |
| element.Minimum = 0; |
| element.Maximum = |
| ((DateTime) e.CellElement.RowInfo.Cells["datePlannedRealisation"].Value - |
| (DateTime) e.CellElement.RowInfo.Cells["dateOrder"].Value).Days; |
| //element.Value1 = days<0?0:days; |
| element.Value1 = days > element.Maximum ? element.Maximum : days; |
| element.Orientation = ProgressOrientation.Left; |
| e.CellElement.Children.Add(element); |
| element.StretchHorizontally = true; |
| element.StretchVertically = true; |
| } |
| } |
Some elements are only because the " ill " demodata in database, but it isn't important. in the if case I try to use the one of the solution but it doesn't work or I don't understand it.
I do no enable editing, adding etc in the grid. It is only for presenting and sorting data. And the scrollinup or scrolling with handling the scrollbar by cursor made mentioned above problem.
I will be greatfull for fast reply with working solution :)