Administrator [Syncfusion]
Replied On December 10, 2002 12:15 PM UTC
Ok, I have some code from the textbox renderer class that we use there to fake Mouse messages. It should take care of the click twice problem.
The other problem with the paint glitch - you should leave that for now. Maybe we'll be able to provide some infrastucture that will take care of such issues in future but I don't know yet.
Here is that code for faking mouse down and up in OnClick:
protected override void OnClick(int rowIndex, int colIndex, MouseEventArgs e)
{
base.OnClick(rowIndex, colIndex, e);
// make sure that we are on the TextBox cell
Grid.InvalidateRange(GridRangeInfo.Cell(rowIndex, colIndex));
CurrencyGrid currencyGrid = GetCurrencyGrid(rowIndex, colIndex);
if(currencyGrid.CurrentCell.HasCurrentCell == false)
{
currencyGrid.CurrentCell.MoveTo(1, 1, GridSetCurrentCellOptions.ForceRefresh|GridSetCurrentCellOptions.SetFocus);
}
GridCellLayout layout = GetCellLayout(rowIndex, colIndex, Grid.Model[rowIndex, colIndex]);
bool clickOnCell = layout.ClientRectangle.Contains(new Point(e.X, e.Y));
Syncfusion.Diagnostics.TraceUtil.TraceCurrentMethodInfo(rowIndex, colIndex, new Point(e.X, e.Y), clickOnCell, layout.ClientRectangle);
bool beginEdit = true;
if (beginEdit)
{
CurrentCell.BeginEdit();
if (CurrentCell.HasControlFocus && e.Button == MouseButtons.Left)
{
Grid.Update();
Point loc = layout.TextRectangle.Location;
Point p = new Point(e.X-loc.X, e.Y-loc.Y);
int lParam = MAKELPARAM(p.X, p.Y);
int wParam = MK_LBUTTON; //(int) e.Button;
PostMessage(currencyGrid.Handle, WM_LBUTTONDOWN, wParam, lParam);
PostMessage(currencyGrid.Handle, WM_LBUTTONUP, wParam, lParam);
}
}
}
const int MK_LBUTTON = 1 /*0x0001*/;
const int WM_LBUTTONDOWN = 513; // 0x0201
const int WM_LBUTTONUP = 514; // 0x0202
internal static int MAKELPARAM(int low, int high)
{
return ((high << 16) | (low & 0xffff));
}
[System.Runtime.InteropServices.DllImport("user32.dll", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
extern static IntPtr PostMessage(IntPtr hwnd, int msg, int wparam, int lparam) ;
I guess you got a really good knowledge how to create your own cell types by now.
Stefan