내가하려는 것은 DocNumber를 참조하여 데이터베이스를 수집하고 DataGrid에 저장하는 것입니다. 검색하는 방법에 의존합니다.ComboBox Column이있는 DataGrid에 값을 추가하는 방법
internal void SelectDetailsRecord(string p)
{
SFCDataContext SFC = new SFCDataContext();
try
{
var DetailsRec = SFC.Sales_OrderFormDetails.Where(w => w.OrderDocNum == p)
.Select(t => new {
Ord = t.OrderDocNum,
Line = t.LineNumber,
Vcode = t.VariantCode,
Vdesc = t.VariantDesc,
Icode = t.Itemnmbr,
Idesc = t.ItemDesc,
Qty = t.Quantity,
UofM = t.UofM,
Kgs = t.KgsPerBag,
Post = t.Posted
});
int count = 0;
foreach (var r in DetailsRec)
{
decimal TotalKgs = Convert.ToDecimal(r.Qty) * Convert.ToDecimal(r.Kgs);
string[] row =
{
r.Qty.ToString(),
r.Icode,
r.Idesc,
r.UofM,
r.Vcode,
r.Vdesc,
r.Kgs.ToString(),
TotalKgs.ToString(),
r.Line.ToString()
};
//DataGridView1.Rows.Add(row); <-- Tried this one but returns me an error statement.
DataGridView1.Rows[count].Cells[0].Value = row[0];
DataGridView1.Rows[count].Cells[1].Value = row[1]; <-- this Part here is the combo box column
DataGridView1.Rows[count].Cells[2].Value = row[2];
DataGridView1.Rows[count].Cells[3].Value = row[3];
DataGridView1.Rows[count].Cells[4].Value = row[4];
DataGridView1.Rows[count].Cells[5].Value = row[5];
DataGridView1.Rows[count].Cells[6].Value = row[6];
DataGridView1.Rows[count].Cells[7].Value = row[7];
DataGridView1.Rows[count].Cells[8].Value = row[8];
count++;
}
}
catch (Exception) { }
SFC.Connection.Close();
}
나는이 같은 콤보 상자에 값을 넣어 같이 DataGrid에 콤보 상자에 레코드의 값을 넣을 수있는 방법이 : 여기 아래에있는 내 기능 코드는 "ComboBox.Text = 값;"도와주세요 anytone에 아이디어가 있다면.
그래서 DataSource 행 [1]의 DataSource가있는 ComboBox가 DataGridView1.Rows [count] .Cells [1]에 포함되어 있습니까? – dursk
row [1]은 데이터베이스 linq 쿼리에서 검색 한 값으로, 문자열에 배치하면 데이터 행 1 행과 동일한 1 행의 데이터를 넣을 수 있습니다. 그러나 각 DataGrid 행에는 셀 [1] 인 콤보 상자 유형의 열이 1 개 포함되어 있으며 나머지는 텍스트 상자에 불과합니다. – John
격자 결합 콤보 상자에 대한 코드를 보여줍니다. –