clicking a button inside tab control/ tab page - revit form - forms

i am trying too use a tabControl panel to put multiple features in a single form.
how can i make a button inside a tab clickable? it seems as if the button is not active when its being clicked from inside its parent tab.
how can i make the button active from inside the tab container?
notes:
i tryied to place a call for the button inside the tabPage, but then - when i clicked the button nothing happened, but when i clicked somewhere random inside the tab itself the button activity started.
buttons decleration + tabcontrol decleration:
// a button to add the associated views to the right listbox (listbox2):
private void button1_Click(object sender, EventArgs e)
{
listBox2.Items.Clear();
selectedItemText = listBox1.SelectedItem.ToString();
selectedItemIndex = listBox1.SelectedIndex;
foreach(Level lev in levels)
{
if(lev.Name == selectedItemText)
{
pickedLevel = lev;
}
}
foreach(Element view in views)
{
View v = view as View;
if (v.GenLevel != null)//check if the view is indeed a level
{
if (v.ViewType == ViewType.CeilingPlan && v.GenLevel.Name == pickedLevel.Name)//check if the plan is cielling, and if it has the same level as chosen
{
listBox2.Items.Add(v.Name);
}
}
}
dataBindings();
}
// set the listbox1 back:
private void dataBindings()
{
listBox1.DataSource = null;
listBox1.DataSource = levelNames;// string list
}
// button to clear the right listbox
private void button2_Click(object sender, EventArgs e)
{
listBox2.Items.Clear();
dataBindings();
}
// the tab decleration--> what goes here?
private void tabPage1_Click(object sender, EventArgs e)
{
}

Related

Pass data back from Maui shell navigation

The App navigates to a view in which the user selects an item on a CollectionView and then navigates back. How do I get the SelectedItem on the page that initiated the navigation?
await Shell.Current.GoToAsync("//SelectAnItem");
//Get the selected item
The App navigates to a view in which the user selects an item on a
CollectionView and then navigates back.
There are several ways to achieve this.
Method 1:A common approach is to use EventHandler.
You can define EventHandler in this view(Suppose the name is SelectedPage), just as follows:
public static EventHandler<Item> mEventHandler; // define a static EventHandler
After you select an item, you can pass the selected item with the following code:
private void Button_Clicked(object sender, EventArgs e)
{
EventHandler<Item> handler = mEventHandler;
if (handler != null)
{
Item item = new Item { Name= "Hello." };
mEventHandler(this, item);
}
Navigation.PopAsync();
}
In the previous page, you can add the following code in the constructor of YourPreviousPage :
SelectedPage.mEventHandler += delegate (object s, Item a)
{
BackCall(s, a);
};
And the code of function BackCall is:
private void BackCall(object send, Item a)
{
if (a == null)
{
throw new ArgumentNullException(nameof(a));
}
else {
DisplayAlert("Alert", "call back value is : " + a.Name, "OK");
}
}
method 2
You can also use MessagingCenter to achieve this function.
Please refer to the following code:
public partial class PreviousPage: ContentPage
{
public PreviousPage()
{
InitializeComponent();
// method 2
MessagingCenter.Subscribe<SelectedPage, Item>(this, "SelectedItem", (obj, item) =>
{
var newItem = item as Item;
DisplayAlert("Alert", "call back value is : " + newItem.Name, "OK");
});
}
}
SelectedPage.xaml.cs
private void Button_Clicked(object sender, EventArgs e)
{
Item item = new Item { Name = "Hello." };
MessagingCenter.Send(this, "SelectedItem", item);
Navigation.PopAsync();
}

How to catch click on eto ImageViewCell?

I have a column in my grid that displays a garbage icon. When clicked I want to catch that click and delete the row.
How do I listen for a click on an ImageViewCell?
gridControl.CellClick += Stats_CellClick;
private void Stats_CellClick(object sender, GridViewCellEventArgs e)
{
if (e.Column == 3)
{
RulesDocAdapter rda = (RulesDocAdapter)e.Item;
rda.Delete();
UpdateRulesDoc(Globals.RulesDoc);
}
}

GWT button click event

i have one window panel in my project.
and i add one button to it.
when i click the button,i want two event to fire.
one event is to hide that window,which i achieve through
Button button = new Button("click");
button.addListener(new ButtonListenerAdapter(){
#Override
public void onClick(Button button, EventObject e) {
hide();
super.onClick(button, e);
}
});
Window.add(button);
and second i want to pop up another window at the same time on the same button click..what to do?
help me out
I think this should solve your problem :
final boolean evenClick = false;
Button button = new Button("click");
button.addListener(new ButtonListenerAdapter(){
#Override
public void onClick(Button button, EventObject e) {
if (!evenClick) {
hide();
super.onClick(button, e);
}
else {
//DO YOUR SECOND CLICK STUFF
}
evenClick = !evenClick;
}
});
Window.add(button);

add View by using WindowManager, but can back key press

I've add a View, by using WindowManager.
It shows properly what I wanted to do,
but I have a problem.
this is the problem.
back key press doesn't affect under android component(like activity)
what I want is my added view can focusable, ( can click the view's inner button )
only when click the view,
and outside of the view can process their work.
( for example, if there is a button, can be clicked, and when back key press, top activity was gone )
but if I add a flag - WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
then I can't receive onClick method on my added view's button.
but back button work correctly.
otherwise, if i remove the flag -I can receive onClick callback,
but now back button doesn't work.
I have a dilema. :(
Thank you.
Have your View override
public boolean dispatchKeyEvent(KeyEvent event)
to do something when back is pressed.
Override dispatchKeyEvent of your View
#Override
public boolean dispatchKeyEvent(KeyEvent event)
{
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK)
{
// handle back press
// if (event.getAction() == KeyEvent.ACTION_DOWN)
return true;
}
return super.dispatchKeyEvent(event);
}
You can do like this:
Add a Float window by WindowManager, for example, add a view to screen bottom:
WindowManager windowManager = (WindowManager) getActivity().getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
layoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
layoutParams.type= WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
layoutParams.format = PixelFormat.TRANSLUCENT;
layoutParams.gravity = Gravity.LEFT | Gravity.TOP;
layoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
FrameLayout view = new FrameLayout(getActivity()) {
#Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
// do you code
return true;
}
return super.dispatchKeyEvent(event);
}
};
windowManager.addView(view, layoutParams);

show modal popup from code behind

i have a dropdownlist
in codebehind,i have this function
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
///////
}
now i want to show modal popup when a particular text is selected from the dropdownlist from this function
if(DropDownList1.SelectedItem.Text.Equals("Some Text"))
{
ModalPopupExtender1.Show();
}