Print Page | Close Window

Adding button

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Property Grid
Forum Description: Topics Related to Codejock Property Grid
URL: http://forum.codejock.com/forum_posts.asp?TID=16808
Printed Date: 07 May 2024 at 9:17pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Adding button
Posted By: madness
Subject: Adding button
Date Posted: 08 June 2010 at 3:44pm
Hello,
 
I am new to codejock and am trying to add a button to property grid item.   I am trying to base this on the samples provided with the product, but am not having much luck.  If anyone could provide a code sample on how to do this, as well as other links to some tutorials, it would be much appreciated.
 
I am trying this with version 13.3.1 with VB.NET 4.0.
 
 
 

Category = Me.AddressPropertyGrid.AddCategory(A.Location_Name.ToString)

Dim istring As String

istring = A.Location_Name.ToString 'dr("location_name")

Item = Category.AddChildItem(XtremePropertyGrid.PropertyItemType.PropertyItemString, "Location Name", A.Location_Name)

Item.ReadOnly = False

Item.EditStyle = PropertyItemEditStyle.EditStyleLeft

Item.Flags = PropertyItemFlags.ItemHasEdit Or PropertyItemFlags.ItemHasExpandButton

Item.Id = 9

Dim Button As XtremePropertyGrid.PropertyGridInplaceButton

Button = Item.AddInplaceButton(1)

Button.Caption = "Test Button"

Button.Enabled = True

 

Thanks,
Madness



Replies:
Posted By: SuperMario
Date Posted: 08 June 2010 at 3:56pm
Here is some c# code to do the same:

            //Inplace Buttons Type Samples
            Category = wndPropertyGrid.AddCategory("Inplace Buttons");
            Item = Category.AddChildItem(PropertyItemType.PropertyItemBool, "Combo Button", true);
            Item = Category.AddChildItem(PropertyItemType.PropertyItemString, "Expand Button", "");
            Item.Flags = PropertyItemFlags.ItemHasEdit | PropertyItemFlags.ItemHasExpandButton;
            Item = Category.AddChildItem(PropertyItemType.PropertyItemString, "2 Buttons", "");
            Item.Flags = PropertyItemFlags.ItemHasEdit | PropertyItemFlags.ItemHasExpandButton | PropertyItemFlags.ItemHasComboButton;
            Item.Constraints.Add ("Windows 98", 1);
            Item.Constraints.Add ("Windows 2000", 2);
            PropertyGridInplaceButton Button;
            Item = Category.AddChildItem(PropertyItemType.PropertyItemString, "Text Button", "");
            Button = Item.AddInplaceButton(1);
            Button.Caption = "Find";
            Item = Category.AddChildItem(PropertyItemType.PropertyItemString, "Image Button", "");
            Button = Item.AddInplaceButton(1);
            Button.IconIndex = 10;
            Button.Tooltip = "Click to set filter";

            wndPropertyGrid.Icons.MaskColor = (uint)HexToDecimal("C8D0D4");
            wndPropertyGrid.Icons.LoadBitmap(IconsPath() + "Filter.bmp", 10, XTPImageState.xtpImageNormal);          
           
            Item = Category.AddChildItem(PropertyItemType.PropertyItemString, "Menu Button", "");
            Item.Flags = PropertyItemFlags.ItemHasComboButton | PropertyItemFlags.ItemHasEdit;
            Item.Id = ITEM_MENUBUTTON;
           

            Item = Category.AddChildItem(PropertyItemType.PropertyItemNumber, "Slider Control", 10);
           
            PropertyGridInplaceSliderControl SliderCtrl;
            SliderCtrl = (PropertyGridInplaceSliderControl)Item.AddSliderControl();
            SliderCtrl.Max = 200;
            
            Item = Category.AddChildItem(PropertyItemType.PropertyItemNumber, "Spin Button", 10);
          
            PropertyGridInplaceSpinButton SpinButton;
            SpinButton = (PropertyGridInplaceSpinButton)Item.AddSpinButton();
            SpinButton.Max = 50;
            
            Item = Category.AddChildItem(PropertyItemType.PropertyItemString, "Hyperlink Button", "");
            Item.Flags = 0;
            Button = Item.InplaceButtons.Add(1);
            Button.Hyperlink = true;
            Button.ShowAlways = true;
            Button.Alignment = 0;
            Button.Caption = "Click Me";
            Button.Width = 0 ; // Auto

and how to respond to the clicks:

        private void wndPropertyGrid_InplaceButtonDown(object sender, AxXtremePropertyGrid._DPropertyGridEvents_InplaceButtonDownEvent e)
        {
            System.Diagnostics.Debug.WriteLine("Inplace button down. Item.Caption = " + e.button.Item.Caption);       
            if (e.button.Item.Id == ITEM_DIRECTORY)
            {
                string strPath = Shell.BrowseForFolder("Directories");
                if (strPath != "")
                {
                    e.button.Item.Value = strPath;
                }
            }

            if (e.button.Item.Id == ITEM_MENUBUTTON)
            {
                int l, t, r, b;
                e.button.Item.GetRect(out l, out t, out r, out b);
                mnuSample.Show(this, CurrentMousePosition);
            }
        }



Posted By: madness
Date Posted: 08 June 2010 at 4:44pm
Thank you.  I will give this a try.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net