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.
Unfortunately, activation email could not send to your email. Please try again.

Currency input type Cell Type

Thread ID:

Created:

Updated:

Platform:

Replies:

1313 Oct 16,2002 02:37 AM Dec 10,2002 10:30 PM Windows Forms 9
loading
Tags: GridControl
Kai Iske
Asked On October 16, 2002 02:37 AM

Hi, I was playing around with the Grid and the supported Cell Types. I would want to create a Cell Type that supports the following: - Enter some numbers - Have a ComboBox from which the user may choose a currency or such The result would be that users could enter some amount of money and select the corresponding currency. Of course, I could to this using adjecent cells, but I would prefer having a control capable of handling this. I'm not that much into creating my own Cell Models/Renderers, but would the Grid support a "composed" control/cell type? Thanks for any help Regards Kai Iske

Administrator [Syncfusion]
Replied On October 16, 2002 08:45 AM

In a release toward the end of November, Essential Grid will allow you to host Windows Forms and ActiveX controls in a cell. So, at that point, you could drop a textbox and combobox on a form, and then use that form as a cell control.

Kai Iske
Replied On October 17, 2002 09:54 PM

> In a release toward the end of November, Essential Grid will allow you to host Windows Forms and ActiveX controls in a cell. So, at that point, you could drop a textbox and combobox on a form, and then use that form as a cell control. > > Thanks, sounds good to me. Kai

Kai Iske
Replied On December 3, 2002 11:52 PM

> In a release toward the end of November, Essential Grid will allow you to host Windows Forms and ActiveX controls in a cell. So, at that point, you could drop a textbox and combobox on a form, and then use that form as a cell control. > > Hi Clay, any news on this feature? Will it be delayed and what is an approximate timeframe for it to be released? Thanks Regards Kai Iske DWS Investments

Administrator [Syncfusion]
Replied On December 4, 2002 02:24 AM

Kai, This was delayed. Support for a wide variety of celltypes will be in the 2.0 release around February of next year. As far as the exact cell you described above, you could probably use the GridinCell celltype illustrated in the GridinCells sample. Just make the embedded grid occupy a single cell in the parent grid. Hide the headers in the embedded grid making it have 1 row and two columns. The first column would be a "TextBox", and the second column would be a "ComboBox". Later today, I'll try to work up a little sample and post it here. Clay

Kai Iske
Replied On December 9, 2002 05:46 AM

Clay, based on your hint, I have started working on my own CellType that uses an embedded grid. However, I have one problem: For the TextBox cell I have set up a GridCellValidateInfo to have the data being validated. When I enter some text (the first time) that is not valid, the exception will be thrown immediately (good). Any subsequent attempts to have the exception being thrown will only work after the "second" deactivation of the cell (not good), i.e. I leave my currency type cell with invalid input and the exception will be thrown only when I activate another cell. I have attached my test project. The code is not pretty nor clean, yet, but after all it's a test project. Maybe you can give me a hint. Anyone: This project also includes some MultiSelect (CheckedListBox) CellType. Maybe its of use for someone or maybe someone can make suggestions on how to improve it. It abuses the CellValue as it expects to receive an ArrayList of selected IDs (DataSource usage) or selected item indexes (ChoiceList usage). Thanks Regards Kai Iske DWS Investments

Administrator [Syncfusion]
Replied On December 9, 2002 11:20 AM

I made some changes to the currency cell type class. The key issue is that the control that is displayed in the cell needs to be moved out of the grid canvas. Otherwise the grid control stays there and the current cell notification system of the grid is bypassed and the grid is not aware if the cell got focus, lost focus etc. See the Hide method. (In the GridInCell renderer sample Hide is automatically called because of the SetControl call in Activating. However, in your sample you have to override Hide because you derive from DropDownCellRenderer and not StaticCellRenderer). Additionaly you have to setup interface methods so that the cell renderer emulates a regular cell, like ControlValue, ControlText properties, Validating method etc. Your dropdown checkbox listbox looks very nice. Good job! Can we mention it in our Grid Knowledgebase as a sample? Stefan

Kai Iske
Replied On December 10, 2002 02:31 AM

Hi Stefan, thanks for your reply and the changes you have applied to the code. I have worked a bit more on that code you have returned and the result is contained in the attached ZIP file. Actually, the Cell Model/Renderer now do what I want (at least). You were right concerning the Renderer. I should not copy&paste too often. It now derives from GridStaticCellRenderer (Hide() is gone now) However I have still two things I don't like too much, though: When I click on the inner grid's ComboBox, with a current cell outside the inner grid, I have to click on the ComboBox twice in order to make it pop up. I have tried faking WM_LBUTTONDOWN messages and sending them to the inner grid, but to no lock. The other thing is that sometimes, with the inner grid's ComboBox button being drawn raised, and the inner grid loses the focus/activation, the ComboBox button does to return to the flat state. This is annoying, but for now I can live with it. The attached ZIP contains both CellType implementations (MultiSelect/Currency). You may link them both to your KB, if you wish. Of course, you may also get in touch with me via email regarding shipping the implementations with the Grid (I could also make use of a Suite License at home :))... Just kidding Anyway, I would be interested in learning what you think about the "new" implementation of the currency CellType, at least I now have something that does the job for me. Don't know whether it is general enough for people out there. Regards Kai Iske DWS Investments

Administrator [Syncfusion]
Replied On December 10, 2002 07:15 AM

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

Kai Iske
Replied On December 10, 2002 10:30 PM

Thanks a lot Stefan. This does the job. Yes, during the past days I have learned quite a lot about Cell Models/Renderers, but this is also due to the great support you and Clay are providing in this Forum. Regards Kai Iske DWS Investments

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;