We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Grid control problem while changing the windows style

Hi,

I am using Syncfusion.Windows.Forms.Grid.GridControl in C# windows form in VS2008. I simply drag and drop the syncfusion grid control from the toolbar to my form and added the below lines of code to register the events of CurrentCellControlGotFocus and CurrentCellControlLostFocus.

when i am running my application and clicked on any cell of my application, i got black rectangle in my form as shown in the attached image.

Kindly guide me how to remove the black rectangle.

public partial class SyncFusionSample : Form
{
[DllImport("user32.dll", EntryPoint = "SetWindowLong")]
public static extern UInt32 SetWindowLongPtr(IntPtr hWnd, int nIndex, UInt32 dwNewLong);

[DllImport("user32.dll", EntryPoint = "GetWindowLong")]
public static extern UInt32 GetWindowLongPtr(IntPtr hWnd, int nIndex);

[DllImport("user32.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);

public SyncFusionSample()
{
InitializeComponent();
this.gridControl1.CurrentCellControlGotFocus += new ControlEventHandler(gridControl1_CurrentCellControlGotFocus);
this.gridControl1.CurrentCellControlLostFocus += new ControlEventHandler(gridControl1_CurrentCellControlLostFocus);
}

protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000; /*WS_EX_COMPOSITED*/

return cp;
}
}

void gridControl1_CurrentCellControlLostFocus(object sender, ControlEventArgs e)
{
UInt32 m_Check = GetWindowLongPtr(Process.GetCurrentProcess().MainWindowHandle, -20 /*GWL_EXSTYLE*/);
UInt32 constValue = 0x02000000;/*WS_EX_COMPOSITED*/

if ((m_Check & constValue) != constValue)
{
SetWindowLongPtr(Process.GetCurrentProcess().MainWindowHandle, -20, m_Check | constValue);
}

}

void gridControl1_CurrentCellControlGotFocus(object sender, ControlEventArgs e)
{
UInt32 m_Check = GetWindowLongPtr(Process.GetCurrentProcess().MainWindowHandle, -20);
UInt32 constValue = 0x02000000;

if ((m_Check & constValue) == constValue)
{
SetWindowLongPtr(Process.GetCurrentProcess().MainWindowHandle, -20, m_Check & ~constValue);
}
}
}



SyncFusion GridcontrolProblem_2fe80bfa.zip

1 Reply

RK Ranjeet Kumar Syncfusion Team November 11, 2009 09:23 AM UTC

Hi Mutpan,

Thanks for your interest in Syncfusion products.

The black rectangular box display in grid cell can be removed by handling the CellClick Event instead of CurrentCellControlGotFocus event that you was handling previously.

void gridControl1_CellClick(object sender, GridCellClickEventArgs e)
{

UInt32 m_Check = GetWindowLongPtr(Process.GetCurrentProcess().MainWindowHandle, -20);
UInt32 constValue = 0x02000000;

if ((m_Check & constValue) == constValue)
{
SetWindowLongPtr(Process.GetCurrentProcess().MainWindowHandle, -20, m_Check & ~constValue);
}


}


BlackBoxRemoval-1396366434.zip

Regards,
Ranjeet Kumar

Loader.
Live Chat Icon For mobile
Up arrow icon