How to access the data grid inside a custom control?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How to access the data grid inside a custom control?



I'm a newbie and I decided to enhance my program's GUI using Krypton Toolkit.
I was able to load it into my project.
The issue that I have created a control with name mycontrol which have a KryptonDataGridView with name mydatagrid.


mycontrol


mydatagrid



In my form, I have the following code:


public partial class Form1 : KryptonForm

private KryptonPage mycontrolpage;
private Control mycontrolcontent;
public Form1()

InitializeComponent();


private KryptonPage NewmycontrolPage()

mycontrolcontent = new mycontrol();
KryptonPage page = new KryptonPage("mypage", null, "OS mypage");
// Add the control for display inside the page
mycontrolcontent.Dock = DockStyle.Fill;
page.Controls.Add(mycontrolcontent);

// Document pages cannot be docked or auto hidden
page.ClearFlags(KryptonPageFlags.DockingAllowAutoHidden

private void Form1_Load(object sender, EventArgs e)

// Setup docking functionality
KryptonDockingWorkspace w = kryptonDockingManager.ManageWorkspace(kryptonDockableWorkspace);
kryptonDockingManager.ManageControl(kryptonPanel, w);
kryptonDockingManager.ManageFloating(this);

mycontrolpage = new KryptonPage NewmycontrolPage() ;
kryptonDockingManager.AddToWorkspace("Workspace", mycontrolpage);




My problem is how to access the grid in mycontrol?


mycontrol





We would need to see the code of your mycontrol class, at least the part that is related to the KryptonDataGridView child control. That being said, as a start, you should declare your variable of type mycontrol, not Control. Replace private Control mycontrolcontent with private mycontrol mycontrolcontent, that could solve your problem if you just can't access the properties of that object. One last thing, you should use meaningful names for your controls and variables; don't use names like mycontrol as it has no meaning to someone else (might be you in the future) reading the code.
– Ahmed Abdelhameed
3 hours ago


mycontrol


mycontrol


Control


private Control mycontrolcontent


private mycontrol mycontrolcontent


mycontrol









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

make 2 or more post in bootsrap

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

Firebase Auth - with Email and Password - Check user already registered