Home Forums WinForms controls Xceed Grid for WinForms buttons in grid cell

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #13982 |

    Hi,

    Little over a year ago ”Odi” stated in this discussion forum that new editor controls would be released, so that adding a button to a cell in a grid would become easier. Since this has not yet happened I tried to apply Odi’s example to create a column of buttons in my databound grid. I can’t seem to get it to work however. The grid is bound to an array that an object exposes. One of the columns contains true/false values. I would like to exchange the “true” occurences with buttons that the user can press.

    Here is the code I tried according to Odis example (http://www.xceedsoft.com/Forums/ShowPost.aspx?PostID=1462):

    //show the true/false column
    grid1.Columns[32].VisibleIndex=1;
    grid1.Columns[32].Visible=true;

    //create button
    System.Windows.Forms.Button btn = new System.Windows.Forms.Button();
    btn.Click += new EventHandler( btn_Click );

    //set CellEditor to our new button
    grid1.Columns[32].CellEditor = new Xceed.Grid.Editors.CustomEditor(btn ,”PD”, true);

    //set CellViewer so that a button is shown in the cell
    grid1.Columns[32].CellViewer = new Xceed.Grid.Editors.ControlViewer( new System.Windows.Forms.Button(), “Text” );

    The row “grid1.Columns[32].CellEditor = new…” causes an error to be thrown. The error is “A property of the specified name does not exist on the control.\r\nParameter name: propertyName”.

    Could you please tell me what I am doing wrong? Perhaps there is a much easier way of adding a button to a cell??

    Best Regards
    Kai Fransson

    Imported from legacy forums. Posted by kaison (had 3956 views)

    Odi [Xceed]
    Spectator
    Post count: 426

    Hi Kai,

    Just so you know, it is coming soon. In November we should have a completed version of Xceed Grid for .NET with the new Editors built-in, though it will not yet be released until another major feature is completed – so it will probably be available for testing by customers.

    Odi

    Imported from legacy forums. Posted by Odi [Xceed] (had 263 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Kai,

    “PD” is not a valid property name for the WindowsForms Button control. If you use “Text”, the exception should be resolved.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 370 views)

    User (Old forums)
    Member
    Post count: 23064

    Hello Jenny!

    Your answer solved my problem. Thank you! I am now able to display a button in the cell where the databound value is “true”. I cannot, however, seem to show another text (caption) on the button than the actual cell value, which is “true”. I would like to show some other text on the button instead. Do you know what the problem might be?

    Best Regards
    Kai

    Imported from legacy forums. Posted by kaison (had 315 views)

    User (Old forums)
    Member
    Post count: 23064

    If you use the “Enabled” property instead of the “Text” property, the button will be enabled for cells that contain <i>true</i> and disabled for cells that contain <i>false</i>.

    Imported from legacy forums. Posted by Tommy (had 388 views)

    User (Old forums)
    Member
    Post count: 23064

    I must be doing something wrong. The buttons show in the row correctly but when I click one, the program shuts down. I have attached a click event to the button and the event fires, but once the event is done, the program just ends. Here is the code:

    AddHandler btn.Click, AddressOf MailMergeButton

    Private Sub MailMergeButton(ByVal sender As Object, ByVal e As EventArgs)
    Dim mailmergeForm As New frmMailMerge

    mailmergeForm.ShowDialog(Me)
    End Sub

    After the form closes, the entire program shuts down.

    Any help would be greatly appreciated!

    Imported from legacy forums. Posted by twlichty (had 5035 views)

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.