Hi everyone,
I meet a trouble that I can't multiselect all cells by mouse drag when we create a big table.
My version is 2014.1.402.20, I use radgridview.
e.g.
1. I create 10 by 10 cells table and gridview is a small one, it will show horizon scroll bar and vertical scroll bar.
2. I want to select all cells by mouse drag but not CTRL+Click.
3. I can't select all of them.
Please review my attachment. Thanks.
I meet a trouble that I can't multiselect all cells by mouse drag when we create a big table.
My version is 2014.1.402.20, I use radgridview.
e.g.
1. I create 10 by 10 cells table and gridview is a small one, it will show horizon scroll bar and vertical scroll bar.
2. I want to select all cells by mouse drag but not CTRL+Click.
3. I can't select all of them.
Please review my attachment. Thanks.
8 Answers, 1 is accepted
0
tony
Top achievements
Rank 1
answered on 04 Mar 2015, 08:44 AM
Hello ervery,
My code:
this.radGridView1.SelectionMode = GridViewSelectionMode.CellSelect;
this.radGridView1.MasterTemplate.MultiSelect = true;
this.radGridView1.MasterTemplate.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect;
My code:
this.radGridView1.SelectionMode = GridViewSelectionMode.CellSelect;
this.radGridView1.MasterTemplate.MultiSelect = true;
this.radGridView1.MasterTemplate.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect;
0
Hello Tony,
Thank you for writing.
This is a known issue with RadGridView multiple selection. You can track its progress, subscribe for status changes and add your vote/comment to it on the following link - feedback item. You can have a look at the introduced workaround in the referred item.
I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Dess
Telerik
Thank you for writing.
This is a known issue with RadGridView multiple selection. You can track its progress, subscribe for status changes and add your vote/comment to it on the following link - feedback item. You can have a look at the introduced workaround in the referred item.
I hope this information helps. Should you have further questions, I would be glad to help.
Dess
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
tony
Top achievements
Rank 1
answered on 26 Mar 2015, 08:47 AM
Sorry, It still has this issue. :(
0
tony
Top achievements
Rank 1
answered on 26 Mar 2015, 08:48 AM
Sorry, It still has this issue.
0
Hello Tony,
Thank you for writing back.
I confirm that when you select a cell and drag the selection first horizontally and then vertically, there are missing selected cells. This case can be handled with the RadGridView.MouseUp event. Here is a sample implementation which should be used together with the already applied workaround:
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik
Thank you for writing back.
I confirm that when you select a cell and drag the selection first horizontally and then vertically, there are missing selected cells. This case can be handled with the RadGridView.MouseUp event. Here is a sample implementation which should be used together with the already applied workaround:
private
void
radGridView1_MouseUp(
object
sender, MouseEventArgs e)
{
int
startColumn =
this
.radGridView1.Columns.Last().Index;
int
endColumn = 0;
int
startRow =
this
.radGridView1.Rows.Last().Index;
int
endRow = 0;
for
(
int
i = 0; i <
this
.radGridView1.SelectedCells.Count; i++)
{
if
(
this
.radGridView1.SelectedCells[i].ColumnInfo.Index < startColumn)
{
startColumn =
this
.radGridView1.SelectedCells[i].ColumnInfo.Index;
}
else
if
(
this
.radGridView1.SelectedCells[i].ColumnInfo.Index > endColumn)
{
endColumn =
this
.radGridView1.SelectedCells[i].ColumnInfo.Index;
}
if
(
this
.radGridView1.SelectedCells[i].RowInfo.Index < startRow &&
this
.radGridView1.SelectedCells[i].RowInfo.Index > -1)
{
startRow =
this
.radGridView1.SelectedCells[i].RowInfo.Index;
}
else
if
(
this
.radGridView1.SelectedCells[i].RowInfo.Index > endRow)
{
endRow =
this
.radGridView1.SelectedCells[i].RowInfo.Index;
}
}
int
scrollBarValue =
this
.radGridView1.TableElement.VScrollBar.Value;
this
.radGridView1.BeginUpdate();
for
(
int
i = startRow; i < endRow + 1; i++)
{
for
(
int
j = startColumn; j < endColumn + 1; j++)
{
if
(!
this
.radGridView1.Rows[i].Cells[j].IsSelected)
{
this
.radGridView1.Rows[i].Cells[j].IsSelected =
true
;
}
}
}
this
.radGridView1.EndUpdate();
this
.radGridView1.TableElement.VScrollBar.Value = scrollBarValue;
}
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik
See What's Next in App Development. Register for TelerikNEXT.
0
tony
Top achievements
Rank 1
answered on 03 Apr 2015, 05:07 AM
Thanks for your reply.
I have another question.
I can't smooth scroll bar to the end after I use your code.
The position of scroll bar will change to start position automatically.
Shall we support 2 selection mode?
1. press ctrl + mouse click to select any cells.
2. drag mouse to select cells what we want.
Thanks.
I have another question.
I can't smooth scroll bar to the end after I use your code.
The position of scroll bar will change to start position automatically.
Shall we support 2 selection mode?
1. press ctrl + mouse click to select any cells.
2. drag mouse to select cells what we want.
Thanks.
0
Accepted
Hello Tony,
Thank you for writing back.
It seems that the smooth scrolling is not affected on my end with the specified version 2014.1.402.40. Please refer to the attached gif file illustrating the behavior on my end after implementing the suggested solution.
However, the horizontal scroll-bar is indeed reset to its left most position which can be avoided with manually storing the horizontal scroll-bar value:
As to the question about selecting cells by using the Ctrl key and cell selection, you should modify a little bit the MouseUp event handler in order not to perform the range selection in this case:
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik
Thank you for writing back.
It seems that the smooth scrolling is not affected on my end with the specified version 2014.1.402.40. Please refer to the attached gif file illustrating the behavior on my end after implementing the suggested solution.
However, the horizontal scroll-bar is indeed reset to its left most position which can be avoided with manually storing the horizontal scroll-bar value:
private
void
radGridView1_MouseUp(
object
sender, MouseEventArgs e)
{
int
startColumn =
this
.radGridView1.Columns.Last().Index;
int
endColumn = 0;
int
startRow =
this
.radGridView1.Rows.Last().Index;
int
endRow = 0;
for
(
int
i = 0; i <
this
.radGridView1.SelectedCells.Count; i++)
{
if
(
this
.radGridView1.SelectedCells[i].ColumnInfo.Index < startColumn)
{
startColumn =
this
.radGridView1.SelectedCells[i].ColumnInfo.Index;
}
else
if
(
this
.radGridView1.SelectedCells[i].ColumnInfo.Index > endColumn)
{
endColumn =
this
.radGridView1.SelectedCells[i].ColumnInfo.Index;
}
if
(
this
.radGridView1.SelectedCells[i].RowInfo.Index < startRow &&
this
.radGridView1.SelectedCells[i].RowInfo.Index > -1)
{
startRow =
this
.radGridView1.SelectedCells[i].RowInfo.Index;
}
else
if
(
this
.radGridView1.SelectedCells[i].RowInfo.Index > endRow)
{
endRow =
this
.radGridView1.SelectedCells[i].RowInfo.Index;
}
}
int
vScrollBarValue =
this
.radGridView1.TableElement.VScrollBar.Value;
int
hScrollBarValue =
this
.radGridView1.TableElement.HScrollBar.Value;
this
.radGridView1.BeginUpdate();
for
(
int
i = startRow; i < endRow + 1; i++)
{
for
(
int
j = startColumn; j < endColumn + 1; j++)
{
if
(!
this
.radGridView1.Rows[i].Cells[j].IsSelected)
{
this
.radGridView1.Rows[i].Cells[j].IsSelected =
true
;
}
}
}
this
.radGridView1.EndUpdate();
this
.radGridView1.TableElement.VScrollBar.Value = vScrollBarValue;
this
.radGridView1.TableElement.HScrollBar.Value = hScrollBarValue;
}
As to the question about selecting cells by using the Ctrl key and cell selection, you should modify a little bit the MouseUp event handler in order not to perform the range selection in this case:
private
void
radGridView1_MouseUp(
object
sender, MouseEventArgs e)
{
if
(ModifierKeys == Keys.Control)
{
return
;
}
//...
}
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik
See What's Next in App Development. Register for TelerikNEXT.
0
tony
Top achievements
Rank 1
answered on 17 Apr 2015, 08:54 AM
Thanks you very much! :)