c# - Open groups and details in Devexpress Grid view by Name -
i'm developing winform application contains devexpress gridview composed follow:
- hotel view (grouped
location
,hotel name
column) - availability view (is detailed view of hotel grid , contains availability selected hotel)
i have data in input: location name
, hotel name
.
when open form need expand corresponding group location , hotel name , open detail view availability hotel.
in attachment can find screenshot of grid row expanded need.
can me that?
the code have tried following, opens location group , not hotel name , it's details.
private void hotelavailabilitygridview_endgrouping(object sender, eventargs e) { focusfirstrecordingrouprow(_hotelname); } public void focusfirstrecordingrouprow(string texttofind) { int grouprow = findgrouprow(_hotelname); if (grouprow >= 0) return; hotelgridview.expandgrouprow(grouprow); hotelgridview.focusedrowhandle = hotelgridview.getchildrowhandle(grouprow, 0); } private int findgrouprow(string texttofind) { int = 1; while (i != gridcontrol.invalidrowhandle) { i--; string value = hotelgridview.getgrouprowvalue(i, hotelgridview.columns[0]).tostring(); if (value == texttofind) { recursexpand(hotelgridview, i); return i; } } return 0; }
the screenshot:
i suggest go through documentation of process group rows
you can check whether group row using below method of view:
int rowhandle = view.focusedrowhandle; if(view.isgrouprow(rowhandle)){}
after that, can set expands status:
bool expanded = view.getrowexpanded(rowhandle); view.setrowexpanded(rowhandle, !expanded);
you can locate row value below, can expand matched row , collapse others require.
using devexpress.xtragrid.views.grid; //... gridview view = gridview1; int rowhandle = -1; { rowhandle = view.locatebyvalue(rowhandle+1, view.columns["is in stock"], false); view.makerowvisible(rowhandle, false); } while(rowhandle != gridcontrol.invalidrowhandle);
references:
how select group rows in xtragrid multi-select mode?
group rows in gridview
selecting row in grouped grid
Comments
Post a Comment