Solutions Schedule for Silverlight - Gantt style drag and drop multi resource scheduling        
         
How To ...
 
 
  Studio Controls .NET v1.4    
         
Using Custom Controls with DBI List (dbiList.dll)
   

DBI List 3.0 (dbiList.dll) uses standard text and combo boxes as its edit control. There are many cases where a third party control would be an ideal option for adding intuitive, direct in-line edit capability.  In this how to example we use the concept of a third party date picker control that has a drop down calendar.

Studio Controls .NET - DBI List control - third part control supportTo use a third party control with dbiList.dll, select a control that exposes the key strokes being passed to the host. The host control will not monitor for key strokes so we look to a third party control for this purpose.

With the third party control established interrupt the control’s current edit mode process and monitor the third party control for the navigation keys being used, determine the new cell to go to after a navigation key is pressed, and then place the list back into edit mode.

 

Following are the steps required for using a third party control:

 

·         Create a column object for the control and add it to the list.  NOTE: The EditType property of that column is set to “UserControl”.

·         If the third party control has a “Parent” property, set it to the host List making it easier for positioning later on.

·         Use the BeforeCellEdit event to test for focus on the appropriate column. Now, move the data from the cell to the user control.

In the following code example we are working with a standard date time picker control:

C#

void dbiList1_BeforeCellEdit(object sender, Dbi.WinControl.BeforeCellEditEventArgs e)

{

    string strText;

    if (e.ColumnIndex == m_nUserControlColumn)

    {

        strText = e.NodeItem.GetCellText(e.ColumnIndex);

        dateTimePicker1.Value = Convert.ToDateTime(strText);

    }

}

VB.NET

Private Sub DbiList1_BeforeCellEdit(sender As System.Object, e As Dbi.WinControl.BeforeCellEditEventArgs) Handles DbiList1.BeforeCellEdit

        Dim strText As String

        If e.ColumnIndex = m_nUserControlColumn Then

            strText = e.NodeItem.GetCellText(e.ColumnIndex)

            dateTimePicker1.Value = Convert.ToDateTime(strText)

        End If

End Sub

·         Use the DisplayUserControl event to actually display the user control. Once again test to make sure the focus is in the correct column or else the user control will be showing up where it is not desired.


C#

void dbiList1_DisplayUserControl(object sender, Dbi.WinControl.DisplayUserControlEventArgs e)

{

    if (e.ColumnIndex == m_nUserControlColumn)

    {

        dateTimePicker1.SuspendLayout();

        dateTimePicker1.Visible = false;

        dateTimePicker1.Location = new Point(e.X, e.Y);

        dateTimePicker1.Width = e.Width;

        dateTimePicker1.Visible = true;

        dateTimePicker1.ResumeLayout();

        dateTimePicker1.Focus();

    }

}

VB.NET

Private Sub DbiList1_DisplayUserControl(sender As System.Object, e As Dbi.WinControl.DisplayUserControlEventArgs) Handles DbiList1.DisplayUserControl

        If e.ColumnIndex = m_nUserControlColumn Then

            dateTimePicker1.SuspendLayout()

            dateTimePicker1.Visible = False

            dateTimePicker1.Location = New Point(e.X, e.Y)

            dateTimePicker1.Width = e.Width

            dateTimePicker1.Visible = True

            dateTimePicker1.ResumeLayout()

            dateTimePicker1.Focus()

        End If

End Sub

 

·         Use the RemoveUserControls event to write back the data from the user control and then hide the user control. NOTE: The developer must test that the focus is in the proper column or the data from the user control may be written back to all cells being edited.

C#

void dbiList1_RemoveUserControls(object sender, Dbi.WinControl.RemoveUserControlsEventArgs e)

{

    if (e.ColumnIndex == m_nUserControlColumn)

        WriteDateTimeBack(e.ColumnIndex);

    dateTimePicker1.Visible = false;

}

VB.NET

Private Sub DbiList1_RemoveUserControls(sender As System.Object, e As Dbi.WinControl.RemoveUserControlsEventArgs) Handles DbiList1.RemoveUserControls

If e.ColumnIndex = m_nUserControlColumn Then

            WriteDateTimeBack(e.ColumnIndex)

        End If

        dateTimePicker1.Visible = False

End Sub

Now set your code for monitoring the keystrokes of the user control for navigation to other cells. By default, the host control will monitor for the <Enter>, <Esc>, <Tab> and <Shift Tab> keys. If you are using other keys for navigation, be sure to have those keys monitored and acted upon by the user control as well.

   
       
    Have a Great Programming Day !  
       
   
       
DBI Support Products Downloads  Purchase
Customers Support Request Form Warehouse Scheduling Framework Trial Downloads Order Page
News Releases FAQ Studio Controls for .NET
Contact Us License Registration Studio Controls for COM
Updates Solutions Schedule for .NET
Utilities Solutions Schedule for COM
Support Policies Staff Scheduler
Product Life Support Extractor - Essential Content Summary
Platform Products
Contact Us
 
   
  all rights reserved  |  copyright  1996 - 2014  |  Terms of Use