using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using WinUI.BaseForms;using WinUI.DataSets;namespace WinUI.Forms.BackOffice{ using WinUI.DataSets; using WinUI.DataAccessLayers; using WinUI.HelperClasses; public partial class frmItemMaintenance : frmButtons { public frmItemMaintenance() { InitializeComponent(); CenterToScreen(); btnOk.Hide(); } private void frmItemMaintenance_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'stockLocationData.STOCKLOCATION' table. You can move, or remove it, as needed. // TODO: This line of code loads data into the 'itemData.ITEMMASTER' table. You can move, or remove it, as needed. //comboBoxEditLocation.DataSource = stockLocationData.Tables[0]; //comboBoxEditLocation.DisplayMember = "Location"; //will not suffice GetComboBoxRows getRows = new GetComboBoxRows(stockLocationData, comboBoxEditLocation,"Location",0); //thought i can do it like this??? } }}
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Configuration;using System.IO;using System.Data.SqlClient;namespace WinUI.HelperClasses{ class GetComboBoxRows { private DataSet dsLocal; private DevExpress.XtraEditors.ComboBoxEdit comboBoxLocal; private string table; int rowLocal; //contructor public GetComboBoxRows(DataSet ds,DevExpress.XtraEditors.ComboBoxEdit name,string tableName,int rowno) { dsLocal = ds; comboBoxLocal = name; table = tableName; rowLocal = rowno; } public void GetRows() { foreach (DataTable dt in dsLocal.Tables) { int i = 0; foreach (DataRow dr in dt.Rows) //loop through rows { comboBoxLocal.Properties.Items.Add(dsLocal.Tables[0].Rows[i][table]); i++; } } } }}