2017-12-26 7 views
0

RepositoryItemRadioGroup의 선정 된 가치를 얻을 필요가 있습니다RepositoryItemRadioGroup의 값을 얻으십시오

나는 그것을 어떻게 얻을 수 있습니까 ??

 for (int i = 0; i < gridView1.RowCount; i++) 
     { 
      int rowHandle = gridView1.GetVisibleRowHandle(i); 


QuestionsAndAnswers row = (QuestionsAndAnswers)((GridView)gridControl1.MainView).GetRow(rowHandle); 
     // row.RadioGroup> represent RepositoryItemRadioGroup 
      //i need to get selected value in row.radiongroup 

     } 
+1

GridView의 GetRowCellValue 메서드를 사용하십시오. 반환 된 값은 선택한 라디오 그룹 항목의 EditValue와 같습니다. – Brendon

+0

데이터베이스에 데이터를 저장해야하므로 어떻게이 이벤트를 사용할 수 있습니까 ?? 버튼 내 코드가 있기 때문에 –

+0

이벤트가 아니라 메서드입니다. 단추의 Click 처리기에서 호출하고 값을 검색 한 다음 데이터베이스를 업데이트하는 데 사용하는 메서드로 전달합니다. – Brendon

답변

0

왜 내가 RadioGroup에 직접 액세스해야하는지 분명하지 않습니다. GridView를 QuestionsAndAnswers 객체 컬렉션에 바인딩 한 경우 모든 값이 이미 양방향 방식으로 QuestionsAndAnswers 속성에 매핑되어 있기 때문에 GridView 행을 반복해서는 안됩니다. 따라서 직접 QuestionsAndAnswers 수집을 반복 :

List<QuestionsAndAnswers> qaList = new List<QuestionsAndAnswers> { 
    new QuestionsAndAnswers(){ Question ="How are you?" } 
} 
// data binding 
gridControl1.DataSource = qaList; 
... 
void getAnswersBtn_Click(object sender, EventArgs e) { 
    foreach (QuestionsAndAnswers qa in qaList){ 
     var answer = qa.Answer; 
     // do something 
    } 
} 

을 다른 방식으로의 GridView를 결합하는 경우, 상세한 설명과 함께 귀하의 질문에 업데이트하십시오 :
- 당신이 데이터에의 GridView 바인딩하는 방법을;
- previous questionthe approach demonstrated by @Alex.T을 사용했는지 여부
- 당신이 읽었는지 그렇지 않던간에 documentation;

그런데 중요한 질문은 - you contacted the DevExpress team direcly이고 그 사람들은 뭐라고 말 했나요?

0
for (int i = 0; i < gridView1.RowCount; i++) 
     { 
     // can't get answer of last record so i added test line in the last record to get all answers without new last record 
      if (i==gridView1.RowCount-1) 
      { 
       continue; 
      } 
      int rowHandle = gridView1.GetVisibleRowHandle(i); 
      string ResultAnswer = (string)gridView1.GetRowCellValue(rowHandle, "Answer"); 
      string ResultQuest = (string)gridView1.GetRowCellValue(rowHandle, "Question"); 

     }