I require a farpoint grid with a small button at each right corner of a cell of a particular column

Posted by: manish-tewary on 8 September 2017, 2:51 pm EST

  • Posted 8 September 2017, 2:51 pm EST

    I require a farpoint grid with a small button at each right corner of a cell of a particular column.


    User can edit the cell manually as well as as can click on the button. On Button Click some action has to be performed.


    I am using farpoint grid in windows c# 4.0. Version is 5.0.3514.2008


    Kindly Help

  • Replied 8 September 2017, 2:51 pm EST

    Thanks, it worked. :)
  • Replied 8 September 2017, 2:51 pm EST

    You would need to implement a custom celltype to do that. Here is a thread discussing implementing a custom cell with text and a button with code you should find helpful

    http://www.clubfarpoint.com/Forums/forums/thread/52459.aspx

  • Replied 8 September 2017, 2:51 pm EST

    Hello,

    You would need to create a custom cell type to have both
    a button and text in a cell. Once you have created the custom cell
    type, you would need to create an instance of this celltype and assign
    it to each cell in the column so that each cell can have a button as
    well as text. I have created a sample depicting how you could create a
    custom
    celltype with a button and text both in the same cell, and clicking on a
    button displays a new form. Kindly have a look at the attached sample.

    Hope it will help you. Please let me know if you have any queries further.

    Thanks,

    Manpreet Kaur
    2012/01/cellwithbutton.zip
  • Replied 8 September 2017, 2:51 pm EST

    Hi Manpreet,


    I implemented the same with a little change. All i have done is the location of button will be at the right corner of the cell instead of left corner. Following are the changes i have done :


    In GetEditorControl Method (values are hardcoded for test)


    New - b.Location = new Point(192, 0)


    Old - b.Location = new Point(0, 0);


    In PaintCell Method


    New - btnRect = new Rectangle(287, r.Y, this.linkIcon.Width, this.linkIcon.Height);


    Old - btnRect = new Rectangle(r.X, r.Y, this.linkIcon.Width, this.linkIcon.Height);


    In tb_Resize Method


    New - tb.Location = new Point(btnRect.Width + 195, 0);


    Old-  tb.Location = new Point(btnRect.Width + 3, 0); 


     


    Issue:  When i try to type something in the textbox, nothing appers while typing but the moment i leave the box the text appears. Can u guide me whr i am wrong?


     


     

     

  • Replied 8 September 2017, 2:51 pm EST

    Hello,

    I would like you to know that you are placing the textbox which is used for editing at a wrong location in the tb_Resize method, which makes it hidden and hence you are not able to see the values when you type in the values. I would request you to replace the following line of code in tb_Resize method:

               tb.Location = new Point(btnRect.Width + 195, 0);

    with the following line of code:

              tb.Location = new Point(0, 0);

    This would show the values in the cell when you start typing. Hope it will help you. Please let me know if you have any queries further.

    Thanks,

    Manpreet Kaur.

  • Replied 8 September 2017, 2:51 pm EST

    I found small problem in above codes.


    If i have more then 1 row and i am clicking of the button of second or third row , still the active  row index is 0. 


    How to solve this problem?


     


    Thank, Manish

  • Replied 8 September 2017, 2:51 pm EST

    Hi Manpreet,


    I am wating for ur reply?

  • Replied 8 September 2017, 2:51 pm EST

    Hello,

    I would like you to know that what you see is the intended behavior, when you click on the button the active cell is still the cell in the first row, so you get the ActiveRowIndex to be 0, however the cell which contains the button later becomes the active cell and then only changes the ActiveRowIndex. The only solution possible for this scenario is to allow the user to click on the button only when the cell is in edit mode which makes the cell to be the Active cell in the sheet and hence gives the correct ActiveRowIndex. I have modified the sample accordingly, as soon as the cell enters the edit mode on a double click, you could click on the button in the cell, and on button click the message box shows the correct ActiveRowIndex.

    Kindly have a look at the attached sample. Hope it will help you. Please let me know if you have any queries further.

    Thanks,

    Manpreet Kaur.


    2012/01/cellwithbutton-2.zip
  • Replied 8 September 2017, 2:51 pm EST

    Thanks :)
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels