How to iterate through TileView items in XtraGrid?

This is related to DevExpress question - How to loop through tiles in TileView, which help me to achieve the required functionality in the XtraGrid using the TileView. I require to implement the selection process for TileView similar to GridView in XtraGrid, but I require to iterate through all the TileView items. TileView actually use TileViewControl internally so it require to access under laying  tileview control items to access more information about the TileViewItems. See the below code snippet:

private void HandleTileItemSelection(TileViewItem tileViewItem)
{
    if ((ModifierKeys & Keys.Control) != Keys.Control)
    {
        Dictionary visibleTiles = ((tileView1.GetViewInfo() as ITileControl).ViewInfo as TileViewInfoCore).VisibleItems;
        int alternateCheckedItemsCount = 0;
        foreach (KeyValuePair item in visibleTiles)
        {
            if (item.Value != tileViewItem && item.Value.Checked)
            {
                alternateCheckedItemsCount++;
                item.Value.Checked = false;
                tileView1.SetRowCellValue(item.Value.RowHandle, "CheckedStatus", false);
            }
        }
    }        
}

How to display tooltip on mouse hover in particular cell or column cell?

Scenario:  

Today I got an assignment to display tooltip on particular column cell depending on its text that contain some specific prefix to create different tool tip text.  The grid control was used is Infragistics UltraWinGrid to populate data to user.

Solution/Description:

Most of the time I work with DevExpress controls and default win form controls, there we have different approach to get the grid element when hovering mouse over the grid element.  These controls use HitTestInfo to determine that which grid element currently hovered. While looking for the solution I found one Stackoverflow thread - DataGridView.HitTestInfo equivalent in Infragistics UltraWinGrid? . I am also hunting for the same question’s answer that does Infragistics’s UltraGrid control provides functionality similar to that of DataGridView.HitTestInfo?

Source - Task-based Tutorial - How to use ToolTips with the Infragistics UltraWinGrid

 I found out that Infragistics controls don't convert the coordinates, but they use a special Infragistics grid event (MouseEnterElement) to get the element, which the mouse currently hovers over. Also with the Infragistics UltraWinGrid-control it required to keep track of the grid-row, over which the cursor is hovering. In contrast to our generic solution, the position is stored in a data-type provided by the UltraWinGrid-control and not in a Point-structure: 

Public Class Form1
    Inherits System.Windows.Forms.Form 
   ...  
    'Holds the row/column-coordinates of the cell on which
    'the mouse is hovering...
    Private mCurrentCell As Infragistics.Win _ 
                .UltraWinGrid.UltraGridCell = Nothing
  ...

The way of implement for the generic grid-control (in the section on "How to use ToolTips with grid-controls"), the whole logic, to keep track of the current mouse-position in terms of grid-coordinates (row/column) and to provide the tooltip with the content of the current grid-element, is located in the MouseEnterMouseLeave and MouseMove event-handlers. This is slightly different for the UltraWinGrid-control. Of course, the needed logic is also coupled to mouse-events, but the UltraWinGrid-control provides additional mouse-related events, which make the integration even easier. 

 

Code snippet to show tooltip while using UltraWinGrid:

private void ultraGrid1_MouseEnterElement(object sender, UIElementEventArgs e)
{
    if (e.Element is RowUIElement)
    {
        if (e.Element.SelectableItem is UltraGridRow)
        {
            UltraGridRow ultraGridRow = (UltraGridRow)e.Element.SelectableItem;

            if (ultraGridRow.Band.Key == PaletteZoneHVACGroupingConstants.BAND_PARENT)
            {
                toolTip.ToolTipText = "Drag-n-drop here";
                toolTip.Show();
            }
        }                
    }
    else if(e.Element is CellUIElement)
    {
        // Get a refernce to the column.
        UltraGridColumn column = (UltraGridColumn)e.Element.GetContext();
        if (column != null && column.Key == ColumnName.DESIGNTEMPLATE)
        {
            UltraGridCell cell = e.Element.SelectableItem as UltraGridCell;
            if (cell.Row.Band.Key == Constants.BAND_PARENT)
            {
                string toolTipMessage = string.Empty;
                if (cell.Text.StartsWith(Constants.TextDesginChangePrefix))
                {
                    toolTipMessage = ResourceMessage.GetMessage(ResourceConstants. DESGINS_CHANGE);
                }
                else if (cell.Text.StartsWith(Constants.TextParametersChangePrefix))
                {
                    toolTipMessage = ResourceMessage.GetMessage(ResourceConstants.DESGINS_PARAMETERS_CHANGE);
                }
                
                if (!string.IsNullOrWhiteSpace(toolTipMessage))
                {
                    toolTip.ToolTipText = toolTipMessage;
                    toolTip.Show();
                }
            }
        }
    }
}

private void ultraGrid1_MouseLeaveElement(object sender, UIElementEventArgs e)
{
    toolTip.Hide();
}

 

References:

How to set UltraToolTipeInfo in perticular row in win ultra grid control.

display tooltip on mouse hover in cell

 

How to open DateTime picker C# control programmatically on Button Click

You have to use interop to to send request to windows that show DataTimePicker 
on click of the button
//include namespace section 
using System.Runtime.InteropServices;

//declares
[DllImport("user32.dll")]
private static extern bool PostMessageForCalender(
IntPtr hWnd, // handle to destination window
Int32 msg, // message
Int32 wParam, // first message parameter
Int32 lParam // second message parameter
);

const Int32 WM_LBUTTONDOWN = 0x0201;

//method to call  calender dropdown
private void button1_Click(object sender, EventArgs e)
{
    Int32 x = dateTimePicker1.Width - 10;
    Int32 y = dateTimePicker1.Height / 2;
    Int32 lParam = x + y * 0x00010000;

    PostMessageForCalender(dateTimePicker1.Handle, WM_LBUTTONDOWN, 1,lParam);

}