I'm developing a Winform application that contains a Devexpress GridView composed as follow:
- Hotel view (grouped by
LocationandHotel Namecolumn) - Availability view (is a detailed view of the hotel grid and contains the availability for the selected hotel)
I have this data in input: Location Name, Hotel name.
When I open the form I need to expand the corresponding group for the location and hotel name and open the detail view with the availability for that hotel.
In the attachment you can find the screenshot of the grid with the row expanded as I need.
Can you help me do that?
The code that I have tried is the following, but it only opens the Location group and not the Hotel name and 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 i = 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:
