Click here to Skip to main content
13,797,606 members
Click here to Skip to main content
Add your own
alternative version


17 bookmarked
Posted 26 Oct 2007
Licenced CPOL

My Flex Grid ActiveX Control

, 26 Oct 2007
Rate this:
Please Sign up or sign in to vote.
Edit Flex grid with Combo box
Screenshot - KFlex.jpg


I have some trials to edit something like any invoice, I found DataGrid unfamiliar, also FlexGrid did not have a method to edit, then I created my ActiveX (user control) using MSFlexGrid, hidden Textbox and hidden Combobox. I gave the name KGrid to my ActiveX. I created a project TestKGrid to test my control. I wrote the code under Visual Studio 2003 and Framework 1.1.

With my ActiveX control, you can:

  • Edit any cell in Flex grid
  • Delete any row
  • Delete all rows and begin with one row
  • Add Combo box to any Column


When using my ActiveX control, the Flex grid will begin with one row as DataGrid control, then increase rows one by one after editing previous row. The grid in my ActiveX control has the name flxGrid, the Combo box in my ActiveX control has the name lstItems.

Using the Code

To use my ActiveX KGrid, you must add the file KFlexgrid.dll to References. You can find this file in the folder TestKGrid\bin\Debug. To add the control to your own form, you have to import it to the toolbox by browsing and adding the item KFlexgrid.dll. When you get it on your toolbox, you just drag it and drop it on your form.

You must add the following files also to References:

  • AxInterop.MSFlexGridLib.dll
  • Interop.MSFlexGridLib.dll

These files are in the folder (TestKGrid\bin\Debug).

Suppose the name of our grid control is kGrid1, we say the name of its grid is flxGrid and the name of its Combo box is lstItems. Now we shall write some lines to use the KGrid control:

// set number of Columns:
kGrid1.flxGrid.Cols = 8;
// set width of second column:
kGrid1.flxGrid.set_ColWidth(1, 2500); // width in Twip as VB6.
// set width to combo box: 
kGrid1.lstItems.Width = 120; // width in Pixel 
// add items to combo box: 
kGrid1.lstItems.Items.Add ("Cairo, Egypt"); 
// add Combo to third column:
kGrid1.ColCombo = 2;
// delete the row under the mouse pointer:
// delete all rows and begin with one:

Points of Interest

I learnt different methods between C# and VB6, as shown in the following examples:

  1. For column width in VB6, we write:
    FlexGrid1.ColWidth(1) = 2500 

    But in C#, we write:

    FlexGrid1.set_ColWidth(1, 2500); //width in Twip as VB6 
  2. View text in the cell at (Row=2) and (Col=3) in VB6, we write:
    FlexGrid1.TextMatrix(2, 3) = "any text" 

    But in C#, we write:

    FlexGrid1.set_TextMatrix(2, 3, "any text");


The file contains:

The folder TestKGrid which contains source files.

TestKGrid\bin\Debug\KFlexgrid.dll // this is my Flex grid ActiveX. 
TestKGrid\bin\Debug\AxInterop.MSFlexGridLib.dll // add to References for any Flex grid. 
TestKGrid\bin\Debug\Interop.MSFlexGridLib.dll // add to References for any Flex grid. 
TestKGrid\bin\Debug\ TestKGrid.exe // executable file to test ActiveX. 

I write this program to test my Flex grid ActiveX KFlexgrid.dll.

The button <Delete Row> to delete any row under mouse pointer.

The button <Delete All> to delete all rows and begin with one row.

The button <Combo Cell> will add Combo box at third column with the following method:

KGrid1.ColCombo = 2; 

But you can add Combo box to any column with code as above after adding some items to the combo box .


I hope my control helps you to edit any table. All friends of CodeProject can use my ActiveX if it is useful.

If you have any ideas, I hope to know and if you find any problem, you can tell me, but in simple English language because my English is poor!

Thanks to CodeProject and to all.

Mostafa Kaisoun


  • 26th October, 2007: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

No Biography provided

You may also be interested in...


Comments and Discussions

GeneralMy vote of 1 Pin
Rakesh Aytha10-Nov-11 18:53
memberRakesh Aytha10-Nov-11 18:53 
GeneralMultiple Combo Pin
notiboy217-Dec-07 3:25
membernotiboy217-Dec-07 3:25 
GeneralRe: Multiple Combo Pin
Mostafa Kaisoun10-Dec-07 13:02
memberMostafa Kaisoun10-Dec-07 13:02 
QuestionMore than 1 combobox ? Pin
notiboy211-Dec-07 0:12
membernotiboy211-Dec-07 0:12 
AnswerRe: More than 1 combobox ? Pin
Mostafa Kaisoun1-Dec-07 12:24
memberMostafa Kaisoun1-Dec-07 12:24 
GeneralRe: More than 1 combobox ? Pin
notiboy211-Dec-07 15:26
membernotiboy211-Dec-07 15:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01 | 2.8.181207.3 | Last Updated 26 Oct 2007
Article Copyright 2007 by Mostafa Kaisoun
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid