Tìm tổng số dòng trong lookupEdit
int idLoc = lookUpDaoTao_TenKhoaHoc.ItemIndex;
int TotalLoc = ((IListSource)lookUpDaoTao_TenKhoaHoc.Properties.DataSource).GetList().Count;
if (idLoc < TotalLoc)
lookUpDaoTao_TenKhoaHoc.ItemIndex = idLoc + 1;
else
lookUpDaoTao_TenKhoaHoc.ItemIndex = idLoc - 1;
Random rnd = new Random();
txtDaoTao_SoBuoiCoMat.Text = rnd.Next(13, 50).ToString(); // creates a number between 13 and 50
calcEditDaoTao_SoBuoiNghiHoc.Value = rnd.Next(3, 1
Hello,
In order to avoid duplicate issue i want to answer about an another problem i have with lookUpEdit control. Namely ti works just fine like this (without touching anything in design view):
dt = New DataTable
da = New OleDb.OleDbDataAdapter("SELECT ID, Title FROM tblVideo ORDER BY Title ASC", oledbcon)
cb = New OleDb.OleDbCommandBuilder(da)
da.Fill(dt)
Me.dxLookUpEdit.Properties.DataSource = dt
Me.dxLookUpEdit.Properties.DisplayMember = dt.Columns(1).ToString
Me.dxLookUpEdit.Properties.ValueMember = dt.Columns(0).ToString
but i want to change the column's captions so i've done something like this:
dt = New DataTable
da = New OleDb.OleDbDataAdapter("SELECT ID, Title FROM tblVideo ORDER BY Title ASC", oledbcon)
cb = New OleDb.OleDbCommandBuilder(da)
da.Fill(dt)
Dim myCol1 As New DevExpress.XtraEditors.Controls.LookUpColumnInfo()
myCol1.Caption = "Movie #"
myCol1.FieldName = "Col1"
Dim myCol2 As New DevExpress.XtraEditors.Controls.LookUpColumnInfo()
myCol2.Caption = "Movie Title"
myCol2.FieldName = "Col2"
Me.dxLookUpEdit.Properties.Columns.Add(myCol1)
'Me.dxLookUpEdit.Properties.Columns.Add(myCol2)
Me.dxLookUpEdit.Properties.DataSource = dt
Me.dxLookUpEdit.Properties.DisplayMember = dt.Columns(1).ToString
Me.dxLookUpEdit.Properties.ValueMember = dt.Columns(0).ToString
From the beginning i thought that there is nothing ... no records/items but then i noticed that if i pop up the control althrough i cannot see the text i can select the items. After i select an item it appears just fine in the lookUpEdit control. Why this happens and how to resolve the same?
Thanks :)
In order to avoid duplicate issue i want to answer about an another problem i have with lookUpEdit control. Namely ti works just fine like this (without touching anything in design view):
dt = New DataTable
da = New OleDb.OleDbDataAdapter("SELECT ID, Title FROM tblVideo ORDER BY Title ASC", oledbcon)
cb = New OleDb.OleDbCommandBuilder(da)
da.Fill(dt)
Me.dxLookUpEdit.Properties.DataSource = dt
Me.dxLookUpEdit.Properties.DisplayMember = dt.Columns(1).ToString
Me.dxLookUpEdit.Properties.ValueMember = dt.Columns(0).ToString
but i want to change the column's captions so i've done something like this:
dt = New DataTable
da = New OleDb.OleDbDataAdapter("SELECT ID, Title FROM tblVideo ORDER BY Title ASC", oledbcon)
cb = New OleDb.OleDbCommandBuilder(da)
da.Fill(dt)
Dim myCol1 As New DevExpress.XtraEditors.Controls.LookUpColumnInfo()
myCol1.Caption = "Movie #"
myCol1.FieldName = "Col1"
Dim myCol2 As New DevExpress.XtraEditors.Controls.LookUpColumnInfo()
myCol2.Caption = "Movie Title"
myCol2.FieldName = "Col2"
Me.dxLookUpEdit.Properties.Columns.Add(myCol1)
'Me.dxLookUpEdit.Properties.Columns.Add(myCol2)
Me.dxLookUpEdit.Properties.DataSource = dt
Me.dxLookUpEdit.Properties.DisplayMember = dt.Columns(1).ToString
Me.dxLookUpEdit.Properties.ValueMember = dt.Columns(0).ToString
From the beginning i thought that there is nothing ... no records/items but then i noticed that if i pop up the control althrough i cannot see the text i can select the items. After i select an item it appears just fine in the lookUpEdit control. Why this happens and how to resolve the same?
Thanks :)
Hi Neal,
When you use the DataTable as the LookUpEdit datasource, you should explicitly cast it to IListSource since it does not implement it itself.
Dim count% = CType(dxLookUpEdit.Properties.DataSource, IListSource).GetList().Count
As for the second question, you should set LookUpEdit columns' FieldName exactly to the fieldname of a datasource used in it:
Dim myCol1 As New DevExpress.XtraEditors.Controls.LookUpColumnInfo()
myCol1.Caption = "Movie #"
myCol1.FieldName = dt.Columns(0).ColumnName
Me.dxLookUpEdit.Properties.Columns.Add(myCol1)
Please let us know if this helps.
Thanks,
Michael.
When you use the DataTable as the LookUpEdit datasource, you should explicitly cast it to IListSource since it does not implement it itself.
Dim count% = CType(dxLookUpEdit.Properties.DataSource, IListSource).GetList().Count
As for the second question, you should set LookUpEdit columns' FieldName exactly to the fieldname of a datasource used in it:
Dim myCol1 As New DevExpress.XtraEditors.Controls.LookUpColumnInfo()
myCol1.Caption = "Movie #"
myCol1.FieldName = dt.Columns(0).ColumnName
Me.dxLookUpEdit.Properties.Columns.Add(myCol1)
Please let us know if this helps.
Thanks,
Michael.
Không có nhận xét nào:
Đăng nhận xét