获得用户控件单击事件SplitContainer的背景下 [英] get the splitcontainer context in user control click event

查看:180
本文介绍了获得用户控件单击事件SplitContainer的背景下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

爵士,
我有一个分裂的容器中,在右侧面板中我有一个usercontrol.In用户控件我有这样的用户控件的观点,新的,编辑etc.Bottom几个按钮的形式将基于开放什么链接被点击左侧导航窗格中。现在,当我点击用户控件的视图按钮,我应该打开其下方的一种新的形式。如何获得的SplitContainer的背景下click事件?另外,如果我要检索的形式值数据库来保存,当我在用户控件点击保存按钮,该怎么办呢?

Sir, I have a split container in which in right panel i have a usercontrol.In the user control i have few buttons like view,new,edit etc.Bottom of that user control a form will open based on what link is clicked on the left side navigation pane. now when i click the user control's view button, i should open a new form below it. how to get the context of splitcontainer in the click event?also if i want to retrieve the form values to save in database when i click the save button in user control, how to do it?

推荐答案

要得到你的点击事件按钮:

To get your button in the click event:

Button clickedButton = (Button)sender;

要得到你的按钮的父(如果它是SplitContainer中,你将不得不使用Parent属性3次,因为第一个将让你的用户控件,第二个 - SplitPanel,它不具有Name属性,第三左侧面板 - 如果你希望你SplitPanel,和第4,你的表单名称)

To get the parent of your button (if it was SplitContainer, you'll have to use Parent property 3 times, because the first one will get you your UserControl, second - left panel of the SplitPanel, which doesn't have a Name property, third - your SplitPanel, and 4th, if you want, your form name)

string splitPanemName = clickedButton.Parent.Parent.Parent.Name;



...或者你可以得到整个SplitPanel对象:

...or you can just get whole SplitPanel object:

SplitPanel currentSplitPanel = (SplitPanel)clickedButton.Parent.Parent.Parent;



...或窗体对象:

...or Form object:

Form currentSplitForm = (Form)clickedButton.Parent.Parent.Parent.Parent;

要做到这一点,你必须确保你的形式组成的,这样你就可以得到在正确的地方正确的控制。

To do this, you have to be sure of the composition of your Form, so you can get the right controls at the right place.

这篇关于获得用户控件单击事件SplitContainer的背景下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆