We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

MultiRow selection in GDBG

Hi, I need help with griddataboudngrid control. I am using GDBG as a list box, where I need to select one or more rows. Q#1 So how can I select entire row when I click on any cell of that row? And if I have one selected and then I click another row then it should show me two rows selected.I can unselect a selected row by simply clicking it on again Q#2 At last if I need, how would I get all selected rows? Thanks

7 Replies

AD Administrator Syncfusion Team April 14, 2005 07:32 PM UTC

Try setting the grid.ListBoxSelectionMode = SelectionMode.One to see if that does what you need. You can also try SelectionMode.MultiExtended to allow selecting more that one row using the control/shift keys. To get the selected rows, try using grid.Selections.GetSelectedRows. GridRangeInfoList rangeList = this.gridControl1.Selections.GetSelectedRows(false, true); foreach(GridRangeInfo range in rangeList) { int count = range.Bottom - range.Top + 1; Console.WriteLine(range.ToString() + "Count :" + count); }


AD Administrator Syncfusion Team April 14, 2005 08:48 PM UTC

It does half of the job. I can select multiple rows now. But there are some problems here. I have grid with three columns here. Right now all three columns are enterable. Now if I click a cell whole row is selected but is click it again on the same cell it doesn’t unselect the selected row until you click on some other cell on same row. So it need it to unselected the row if I click it again doesn’t matter which cell I click on same row. I am sure you small trick can help me out. I have one quicker question. Out of these three columns in GDBG I want one column to be read-only. How can I make a column read-only. Please do reply! >Try setting the grid.ListBoxSelectionMode = SelectionMode.One to see if that does what you need. You can also try SelectionMode.MultiExtended to allow selecting more that one row using the control/shift keys. > >To get the selected rows, try using grid.Selections.GetSelectedRows. > >GridRangeInfoList rangeList = this.gridControl1.Selections.GetSelectedRows(false, true); > >foreach(GridRangeInfo range in rangeList) >{ >int count = range.Bottom - range.Top + 1; >Console.WriteLine(range.ToString() + "Count :" + count); >} > >


AD Administrator Syncfusion Team April 14, 2005 08:54 PM UTC

If you want to unselect a row be clicking it a second time, then try the SelectionMode.MultiSimple setting. To make a column readonly, you set its GridBoundColumn.StyleInfo.readOnly property. // if you have added GridBoundColumns this.gridDataBoundGrid1.GridBoundColumns["Price"].StyleInfo.ReadOnly = true; // if you haven’t explicitly added GridBoundColumns this.gridDataBoundGrid1.Binder.InternalColumns["Price"].StyleInfo.ReadOnly = true;


AD Administrator Syncfusion Team April 14, 2005 09:11 PM UTC

Hi, >SelectionMode.MultiSimple thats what i did. still if you click on same cell it doesn''t unselect the row? About ReadOnly, Thanks, It is readonly but when you click on that cell, the cell is selected and you see the focus on that cell. i just don''t want user to have control over that column. it should not feel like that you can edit it. thanks >If you want to unselect a row be clicking it a second time, then try the SelectionMode.MultiSimple setting. > >To make a column readonly, you set its GridBoundColumn.StyleInfo.readOnly property. > >// if you have added GridBoundColumns >this.gridDataBoundGrid1.GridBoundColumns["Price"].StyleInfo.ReadOnly = true; >// if you haven’t explicitly added GridBoundColumns >this.gridDataBoundGrid1.Binder.InternalColumns["Price"].StyleInfo.ReadOnly = true; >


AD Administrator Syncfusion Team April 14, 2005 11:04 PM UTC

You can handle CurrentCellMoved to work around this problem. To make it so the readonly cell''s do not show a cursor, you can handle CurrentCellStartEditing. Here is a sample. http://www.syncfusion.com/Support/user/uploads/GDBD_Selection_bbb1ea6b.zip


AD Administrator Syncfusion Team April 15, 2005 12:55 AM UTC

Thanks, It worked. I have another problem here. when i assign a datatable to my GDBG, i see one extra row at the end. even if i click on the very last cell it also add one more row. i don''t need this. i dont want any extra row. please also help me with this. Thanks >You can handle CurrentCellMoved to work around this problem. To make it so the readonly cell''s do not show a cursor, you can handle CurrentCellStartEditing. Here is a sample. >http://www.syncfusion.com/Support/user/uploads/GDBD_Selection_bbb1ea6b.zip > >


AD Administrator Syncfusion Team April 15, 2005 01:37 AM UTC

Try setting: this.gridDataBoundGrid1.EnableAddNew = false;

Loader.
Up arrow icon