본문 바로가기
DevExpress

GridLookupEdit에 다중선택값 표시하기

by 하_늘_바_람 2021. 3. 26.
// 
private void Form_Load(object sender, EventArgs e) {
	ccbDivCodes.ShowPopup();
    ccbDivCodes.ClosePopup();
}

private void ccbDivCodes_CloseUp(object sender, CloseUpEventArgs e) {
    ccbDivCodes.Refresh();
}

private void ccbDivCodes_CustomDisplayText(object sender, CustomDisplayTextEventArgs e) {
    e.DisplayText = string.Empty;

    if (grdDiv.RowCount == 0) {
        e.DisplayText = e.Value.ToString();
    }
    else {
        foreach (var idx in grdDiv.GetSelectedRows()) {
            e.DisplayText += ";" + grdDiv.GetDataRow(idx)["DivNM"].ToString();
        }

        e.DisplayText = e.DisplayText.Length > 2 ? e.DisplayText.Substring(1) : "";
    }
}

private void SetSelectRowDivCodeGrid(string divcodes) {
    if (divcodes.Length < 2) {
        return;
    }
    else {
        var items = divcodes.Split(",".ToCharArray());

        if (items == null)
            return;
        string selText = string.Empty;
        if (grdDiv.RowCount > 0) {
            for (int i = 0; i < grdDiv.RowCount; i++) {
                var row = (grdDiv.GetRow(grdDiv.GetVisibleRowHandle(i)) as DataRowView).Row as DSBizTalking.BTCDivListRow;
                if (row != null && items.Contains(row.DivCode)) {
                    grdDiv.SelectRow(i);
                    selText += ";" + row.DivNM;
                }
            }
        }
        else {
            dtBTCDivList.Where(w => items.Contains(w.DivCode)).ToList().ForEach((val) => {
                selText += ";" + val.DivNM;
            });
        }
		
        // CustomDisplayText 이벤트를 호출한다.
        ccbDivCodes.EditValue = selText.Length < 2 ? "" : selText.Substring(1);
    }
}

'DevExpress' 카테고리의 다른 글

컬럼 설정하기  (0) 2021.09.23
프로그램 전체에 폰트 적용하기  (0) 2021.03.24
GridLookupEdit 사용법  (0) 2021.03.24