Thứ Hai, 14 tháng 10, 2013

Devexpress

2.checkbox in trong grid gridview









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




0
    • I found an article in your knowledge base that describes how to get a number of items of lookupEdit but in C#. Althrough i am C# programmer too i couldn't convert this code to VB.NET
      int count = (dxLookUpEdit.Properties.DataSource as IList).Count;
      I came with this at the end but it throws an exception: Unable to cast object of type 'System.Data.DataTable' to type 'System.Collections.IList'.
      Dim count% = (CType(dxLookUpEdit.Properties.DataSource, IList)).Count
      I have also tried by using ConversionHelpers.AsWorkaround method but obviously it wasn't solution as well.
      Thanks in advance for any assistance :)

0
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 :)

0
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.

0
Perfect !!!
Thanks for the suggestions.
But, honestly this controls differ too much from the standard controls that come with VS.NET.
Sometimes i feel like i am n00b programer who just started to learn a new VS.NET IDE.
However as they looks amazing it is worthy for the effort.
Regards ;)

0
Hi Neal,
I am happy to hear that my assistance was helpful to you.
Thanks,
Michael.
.........

Không có nhận xét nào:

Đăng nhận xét