ASPxTabControl created dynamically does not receive input events - c#

I have a ASP page with a ASPxTabControl created dynamically (in C#/code behind). The first tab is selected.
But for some reason if I click the 2nd tab, it does not get selected. Any idea's why this could be the case?
Here is my C# code:
Label question1 = new Label();
question1.Text = "Vraag 1";
question1.Font.Bold = true;
placeHolderVrResults.Controls.Add(question1);
ASPxTabControl tabQuestion1 = new ASPxTabControl();
tabQuestion1.TabStyle.BackColor = Color.White;
tabQuestion1.Paddings.PaddingLeft = 0;
tabQuestion1.Paddings.PaddingRight = 0;
tabQuestion1.Enabled = true;
tabQuestion1.EnableClientSideAPI = true;
Tab tab1 = new Tab();
tab1.Text = "1";
tab1.ActiveTabStyle.BackColor = Color.FromArgb(0, 26, 171, 178);
Tab tab2 = new Tab();
tab2.Text = "2";
tab2.ActiveTabStyle.BackColor = Color.FromArgb(0, 26, 171, 178);
tabQuestion1.Tabs.Add(tab1);
tabQuestion1.Tabs.Add(tab2);
placeHolderVrResults.Controls.Add(tabQuestion1);
If I use ASPxTabControl in the .aspx page, then it just works.
So I must be missing some property of ASPxTabControl which needs to be set such that it can receive input/mouse events?
BR, Rene

Your code looks fine, and this works perfectly for me DevExpress Version=16.1.6.0
ASPxTabControl tab = new ASPxTabControl();
tab.Tabs.Add(new Tab("hi"));
tab.Tabs.Add(new Tab("2"));
this.PanelContent3.Controls.Add(tab);
But each project is different, so always you can open a ticket in DX support, they are very nice and will help you for sure.

Related

c# Help creating a new tab with new rdp session in side of it

Any advice greatly appreciated.
I'm trying to dynamically create a tab, and inside of that tab, create a new rdp control.
I've got the tab creation fine. The RDP session seems like it's running through the code, but it never renders anything on the screen and never errors out.
I have the tab presented, but with no content.
Thanks.
TabPage myTabPage = new TabPage(tabtitle);
tabControl1.TabPages.Add(myTabPage);
AxMsTscAxNotSafeForScripting rdp4 = new AxMSTSCLib.AxMsTscAxNotSafeForScripting();
((System.ComponentModel.ISupportInitialize)(rdp4)).BeginInit();
rdp4.CreateControl();
myTabPage.Controls.Add(rdp4);
rdp4.Dock = System.Windows.Forms.DockStyle.Fill;
rdp4.Enabled = true;
rdp4.Location = new System.Drawing.Point(3, 3);
rdp4.Name= targetdevice;
rdp4.OcxState = ((System.Windows.Forms.AxHost.State)(new ComponentResourceManager(typeof(Form1)).GetObject("rdp4.OcxState")));
rdp4.Size = new System.Drawing.Size(574, 529);
rdp4.TabIndex = 0;
var settings = (MSTSCLib.IMsRdpClientAdvancedSettings8)rdp4.AdvancedSettings;
settings.allowBackgroundInput = 1;
settings.ClientProtocolSpec = MSTSCLib.ClientSpec.FullMode;
settings.ConnectToServerConsole = true;
settings.EnableCredSspSupport = true;
settings.EncryptionEnabled = 1;
settings.SmartSizing = true;
rdp4.DesktopHeight = 768;
rdp4.DesktopWidth = 1366;
rdp4.Server = targetdevice;
rdp4.UserName = txt_user.Text;
IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp4.GetOcx();
secured.ClearTextPassword = txt_password.Text;
rdp4.Connect();
tabControl1.SelectedTab = myTabPage;

ListView adding an empty colomn

I have my listView in C#. It should have only one colomn, and also the attribute fo Colomns shows it has only one colomn, but the display shows two:
The ListView is initiated very simply, using
initializeComponenet()
which contains following code:
**this.lstDS.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.DirectoryHeader});**
this.lstDS.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.75F);
this.lstDS.ForeColor = System.Drawing.Color.White;
this.lstDS.FullRowSelect = true;
this.lstDS.HideSelection = false;
this.lstDS.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
listViewItem1,
listViewItem2});
this.lstDS.Location = new System.Drawing.Point(75, 152);
this.lstDS.MultiSelect = false;
this.lstDS.Name = "lstDS";
this.lstDS.Size = new System.Drawing.Size(203, 138);
this.lstDS.TabIndex = 37;
this.lstDS.UseCompatibleStateImageBehavior = false;
this.lstDS.View = System.Window
if you ask yourself - here's DirectoryHeader:
private ColumnHeader DirectoryHeader;
But for any reason, it appears as if it has 2 columns.
Any idea what to check?
Thanks!

Is there away to get a checkbox checked status

I have check boxes that are created by code depending on a database result.
var checkbox = new CheckBox(this);
var checkBoxes = new CheckBox[0];
//in a for loop I have
checkBox.LayoutParameters = new ViewGroup.LayoutParams(LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent);
line view.AddView(checkBox);
Array.Resize(ref checkBoxes, i + 1);
CheckBoxes[i] = checkBox;
All works, I get my checkBoxes that contain a all the name tables from the database so I have 4 tables I get 4 checkboxes
The issue is I'm not sure on the best way to check if its checked.
Any help would be appreciated
Tried if statement to check if the checkBox.Checked and Al's tried
checking if it's TRUE, however seams the if statement has no affect
Have you assigned value true for your checkBox's property Checked?
If you didn't do this,then the value of the checkBox.Checked will be the default value false.
You can refer to the following code,I tested on my side, it works properly.
var layout_main = new LinearLayout(this);
LinearLayout.LayoutParams p2 = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MatchParent,
LinearLayout.LayoutParams.WrapContent
);
layout_main.LayoutParameters = p2;
layout_main.Orientation = Orientation.Vertical;
LinearLayout.LayoutParams param_btn = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);
param_btn.SetMargins(0,500,0,0);
var myBtn = new Button(this);
myBtn.LayoutParameters = param_btn;
myBtn.Text = "chang text";
myBtn.Gravity = GravityFlags.Center;
LinearLayout.LayoutParams param_checkbox = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);
param_btn.SetMargins(0, 100, 0, 0);
var checkBox = new CheckBox(this);
checkBox.LayoutParameters = param_checkbox;
checkBox.Gravity = GravityFlags.Center;
checkBox.Text = "test";
checkBox.Checked = true;
myBtn.Click += delegate {
if (checkBox.Checked)
{
Toast.MakeText(this, "---> checkBox's checked = " + checkBox.Checked, ToastLength.Long).Show();
}
};
layout_main.AddView(myBtn);
layout_main.AddView(checkBox);

Loading data dynamically into the Repeater from code behind file

The question may be a bit long :
I am making an Online Evaluation Portal and there different type of questions in database which needs to be loaded in the web- form. The questions can be Single Answer(radio button) or multi-answer(check box button). So depending upon the type I create the radio button or check box as per requirement and load it in the Repeater during Runtime. The code is as below :
SqlCommand cmd = new SqlCommand("select * from tbl_QuestionAnswer", con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
if ((string)dr["type"] == "SingleAnswer")
{
RadioButton rAnswer1 = new RadioButton();
rAnswer1.ID = "rbl_Answer1";
rAnswer1.GroupName = "QAnswer1";
rAnswer1.Text = dr["Answer1"].ToString();
Panel PAnswer1 = e.Item.FindControl("PAnswer1") as Panel;
PAnswer1.Controls.Add(rAnswer1);
RadioButton rAnswer2 = new RadioButton();
rAnswer2.ID = "rbl_Answer2";
rAnswer2.GroupName = "QAnswer1";
rAnswer2.Text = dr["Answer2"].ToString();
Panel PAnswer2 = e.Item.FindControl("PAnswer2") as Panel;
PAnswer2.Controls.Add(rAnswer2);
RadioButton rAnswer3 = new RadioButton();
rAnswer3.ID = "rbl_Answer3";
rAnswer3.GroupName = "QAnswer1";
rAnswer3.Text = dr["Answer3"].ToString();
Panel PAnswer3 = e.Item.FindControl("PAnswer3") as Panel;
PAnswer3.Controls.Add(rAnswer3);
RadioButton rAnswer4 = new RadioButton();
rAnswer4.ID = "rbl_Answer4";
rAnswer4.GroupName = "QAnswer1";
rAnswer4.Text = dr["Answer4"].ToString();
Panel PAnswer4 = e.Item.FindControl("PAnswer4") as Panel;
PAnswer4.Controls.Add(rAnswer4);
}
else
{
CheckBox cAnswer1 = new CheckBox();
cAnswer1.ID = "chk_Answer1";
cAnswer1.Text = dr["Answer1"].ToString();
Panel PAnswer1 = e.Item.FindControl("PAnswer1") as Panel;
PAnswer1.Controls.Add(cAnswer1);
CheckBox cAnswer2 = new CheckBox();
cAnswer2.ID = "chk_Answer2";
cAnswer2.Text = dr["Answer2"].ToString();
Panel PAnswer2 = e.Item.FindControl("PAnswer2") as Panel;
PAnswer2.Controls.Add(cAnswer2);
CheckBox cAnswer3 = new CheckBox();
cAnswer3.ID = "chk_Answer3";
cAnswer3.Text = dr["Answer3"].ToString();
Panel PAnswer3 = e.Item.FindControl("PAnswer3") as Panel;
PAnswer3.Controls.Add(cAnswer3);
CheckBox cAnswer4 = new CheckBox();
cAnswer4.ID = "chk_Answer4";
cAnswer4.Text = dr["Answer4"].ToString();
Panel PAnswer4 = e.Item.FindControl("PAnswer4") as Panel;
PAnswer4.Controls.Add(cAnswer4);
}
}
But the problem here is all the answers get loaded in all questions. i.e. from that dr["Answer1"] it takes all the data in the "Answer1" column and then makes a check-box or radio-button. I don't know why that is happening as it should take only onr row at a time and data from that row only.
Also this runs good till 2 questions. After that if I add 3rd question and try to load it, it gives error saying "Multiple controls with the same ID 'rbl_Answer1' were found. FindControl requires that controls have unique IDs.". And this is correct too. So I need a approach to load questions into the web-form dynamically depending on Single answer or multi -asnwer
It's very clear that you may create control with the same id if you have more than one row in your query.
Try to make dynamic field/control and set dynamic ID for those control
while (dr.Read())
{
if ((string)dr["type"] == "SingleAnswer")
{
RadioButton rAnswer1 = new RadioButton();
rAnswer1.ID = "rbl_Answer" + dr["AnswerID1"].ToString();
or something like that...

Add LayoutAnchorable programmatically on AvalonDock

I'm trying to add a new Control to AvalonDock from code.
Here`s the code:
var test = new LayoutAnchorable();
test.Title = "teste";
test.IsActive = true;
test.IsSelected = true;
test.ContentId = "search12";
test.Content = new TextBox();
test.AddToLayout(dockingManager, AnchorableShowStrategy.Right);
The new panel shows up, but the Content doesn't (just gray panel).
Why?

Categories

Resources