C# .NET - tab ctrl btn cliked

Asked By Trisha
10-Feb-12 12:06 AM
i m using tabcontol.. which has 4 tab page.. and i want that when user click on first tab then msg box should be shown first tab clicked and when clicks second then should be shown second tab clikced... i dont know on which event i have to write code.. i want to write code seprately for each tab page when button clicked.
  Venkat K replied to Trisha
10-Feb-12 12:42 AM

Use TagbControl selected changed event instead, or you can also recognize the Enter event when the tab page is clicked in show the message box:
User Control:

namespace TestPropogateTabEvent

{

public partial class UserControlWithTab : UserControl

{

public UserControlWithTab()

{

InitializeComponent();

}

public delegate void TabSelectionEventHandler(object sender, EventArgs e);

public event TabSelectionEventHandler PropogateSelectionChange;

private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
 {

  if (PropogateSelectionChange != null)
  {
   PropogateSelectionChange(sender, e);
  }

}

}

}

Form Class:

namespace TestPropogateTabEvent

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

userControlWithTab1.PropogateSelectionChange += new UserControlWithTab.TabSelectionEventHandler(userControlWithTab1_PropogateSelectionChange);

}

void userControlWithTab1_PropogateSelectionChange(object sender, EventArgs e)

{

MessageBox.Show("Tab In User Control Pressed");

}

}

}
 


Thanks

  dipa ahuja replied to Trisha
10-Feb-12 06:18 AM
Simply implement the SelectedIndexChanged event of tab

private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
  MessageBox.Show("you are at " + tabControl1.SelectedTab.ToString() + " Tab");
 
}
Create New Account
help
control events. Giving InvalidCastException I need to override Combobox.SelectedIndexChanged event. I tried having CustomEventArgs Class inherited from System.EventArgs Class. I need to bind instance of CustomEventArgs to Combobox.SelectedIndexChanged event. What would be the doing DirectCast Operation too. But invain. here is the code. Thanks for any help. Public Class Form1 Private Sub Form_load( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me .Load BuildComboBox() End Sub Public Sub BuildComboBox() Dim ComboBox1 As ComboBox = New ComboBox didn't work ''selectedIndex event declaration: ''Public Event SelectedIndexChanged(sender as Object, e As System.EventArgs) ''How to bind cbEvg to ComboBox1_SelectedIndexChanged. . ? AddHandler ComboBox1.SelectedIndexChanged, AddressOf ComboBox1_SelectedIndexChanged Me .Controls.Add(ComboBox1 sender As Object , ByVal e As ComboBoxEventArgs) 'Gives InvalidCastException???? 'Do some calculation End Sub End Class Public Class ComboBoxEventArgs Inherits System.EventArgs Private _data1 As String = "" Private _data2 As Integer = 0 Public Sub
Passing variables from a form to a usercontrol Hi there! i'm new to this forum and new to c# language! These past number of UserControls. I wish to pass a variable from the Form to one specific UserControl. I was trying this. . Code in Form1: public partial class Form1 : Form { / / instance of a containing UserControl userControl ctrl = new userControl(); public frmAdmin() { InitializeComponent(); } private void Form1_Load( object sender, EventArgs e) { / / setting ctrl.UserID value to "hello" but it is remaining to value null :S ctrl.UserID = "hello" ; } } Code in userControl: public partial class userControl : UserControl { private string userID; public string UserID { get { return userID; } set
run base and inherited method .NET Framework Public MustInherit Class A Public Sub method1() . . . End sub End Class Partial Class B Inherits A Public Sub method1() . . . End sub End Class I create an instance of B, but when I call methodA, I would like that 1. would be executed method1 - base class A 2. then would be executed method1 - derived class B is it possible? how? tnx very much VB.NET Discussions UserControl (1) EventArgs (1) VB (1) Control (1) OnDoubleClick (1) CustomControl (1) MustInherit (1) Overridable (1) The compiler
OnMove for a UserControl .NET Framework How can I get an OnMove message for a UserControl? C# Discussions UserControl (1) EventArgs (1) PointToScreen (1) Control (1) Random (1) Application (1) Button (1) ParentChanged (1) Seems like to the form to catch this. using System; using System.Windows.Forms; using System.Drawing; class Test : UserControl { static void Main() { Random rand = new Random(); using(Form f = new Form()) using(Button b rand.Next(f.Width), rand.Next(f.Height)); }; Application.Run(f); } } protected override void OnMove(EventArgs e) { ParentForm.Text = "OnMove:" + Location; } } To complete this to detect a change at any level: using System; using System.Windows.Forms; using System.Drawing; using System.Collections.Generic; class Test : UserControl { static void Main() { Random rand = new Random(); using(Form f = new Form()) using
Reflection .NET Framework Good afternoon. I have a two classes public partial class ContactUsFormSelector : System.Web.UI.UserControl { private bool _ContactUsForm; private string lblTitle = ""; protected void Page_Load(object sender, EventArgs e) { } public bool CustomContactUsSelector { get { return _ContactUsForm; } set { _ContactUsForm = value; } } public string ControlCaption { get { return lblTitle; } set { lblTitle = value; } } } } And secont class class Two { public string GetVal() {} } In the body of second class I need to get a property that stores in the first class? How could I do that? C# Discussions System.Web.UI.UserControl (1) UserControl (1) EventArgs (1) CustomContactUsSelector (1) ContactUsFormSelector (1) ContactUsForm (1) Load (1) ValueTwo (1