I have Windows Form Application. There are 2 standart controls on a form as linklabel and reportviewer. Data represented on reportViewer control sometimes so long and there possible some scrolling to keep all data for reading. It's normal situation.
But I need simple feature, when user is scrolling up or down, linkLabel should move depend scrolling values to up or down, synchronously reportViewer content. LinkLabel location must be fixed comparatively reportViewer
InitializeComponent method included:
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HRCard));
this.reportViewer1 = new Microsoft.Reporting.WinForms.ReportViewer();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.SuspendLayout();
//
// reportViewer1
//
this.reportViewer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.reportViewer1.LocalReport.ReportEmbeddedResource = "Kadr_Azerenerji.Report1.rdlc";
this.reportViewer1.Location = new System.Drawing.Point(0, 0);
this.reportViewer1.Name = "reportViewer1";
this.reportViewer1.Size = new System.Drawing.Size(1020, 730);
this.reportViewer1.TabIndex = 0;
this.reportViewer1.RenderingComplete += new Microsoft.Reporting.WinForms.RenderingCompleteEventHandler(this.reportViewer1_RenderingComplete);
this.reportViewer1.Scroll += new System.Windows.Forms.ScrollEventHandler(this.reportViewer1_Scroll);
//
// linkLabel1
//
this.linkLabel1.AutoSize = true;
this.linkLabel1.Location = new System.Drawing.Point(160, 314);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(45, 15);
this.linkLabel1.TabIndex = 2;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "Diplom";
this.linkLabel1.Visible = false;
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
//
// HRCard
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(1020, 730);
this.Controls.Add(this.linkLabel1);
this.Controls.Add(this.reportViewer1);
this.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "HRCard";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "Azərenerji Kadr";
this.TransparencyKey = System.Drawing.Color.LavenderBlush;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.HRCard_FormClosing);
this.Load += new System.EventHandler(this.HRCard_Load);
this.Scroll += new System.Windows.Forms.ScrollEventHandler(this.HRCard_Scroll);
this.ResumeLayout(false);
this.PerformLayout();
How can I do this ?
Related
When I create transparent applications with WebView2 c# form,
It is not possible to click on visible elements.
When I click, it clicks on the window behind.
I don't have the problem with WebBrowser
Do you have a solution ?
Thank you
//
// webView21
//
this.webView21.CreationProperties = null;
this.webView21.DefaultBackgroundColor = System.Drawing.Color.Transparent;
this.webView21.Location = new System.Drawing.Point(462, 12);
this.webView21.Name = "webView21";
this.webView21.Size = new System.Drawing.Size(337, 429);
this.webView21.Source = new System.Uri("https://***", System.UriKind.Absolute);
this.webView21.TabIndex = 2;
this.webView21.ZoomFactor = 1D;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.webBrowser1);
this.Controls.Add(this.webView21);
this.Name = "Form1";
this.Text = "Form1";
this.TransparencyKey = System.Drawing.Color.Transparent;
((System.ComponentModel.ISupportInitialize)(this.webView21)).EndInit();
this.ResumeLayout(false);
I am making a form system where i need to find a panel to change it's background using string imploration. I have done something similar for a label using the code below where numberEntered is a seperate interger in the program.
Label label = Controls.Find($"Num{numberEntered}", true).OfType<Label>().FirstOrDefault();
label.Text = "Text"
How can I do something similar for a panel where where I can find a panel using a seperate variable in the name? Such as $"Panel{number}"
I have already tried this:
Panel panel = Controls.Find($"Ans{answerNum}Panel", true).OfType<Panel>().FirstOrDefault();
panel.BackgroundImage = Programming_Project.Properties.Resources.MutliChoiceCorrectSelected;
However it throws a NullReferenceException. Any help is much appreciated!
Try it this way please:
String ctlName = $"Ans{answerNum}Panel";
Panel panel = this.Controls.Find(ctlName, true).FirstOrDefault() as Panel;
if (panel != null) {
panel.BackgroundImage = Programming_Project.Properties.Resources.MutliChoiceCorrectSelected;
}
else {
MessageBox.Show("Unable to find " + ctlName);
}
You can try to open Form1.Designer.cs where Form1 is your form name.
Then find the panel code and modify it.
That's how I tried and it worked.
It should look something like this:`
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// panel1
//
**this.panel1.BackColor = System.Drawing.SystemColors.ActiveCaption;**
this.panel1.Location = new System.Drawing.Point(169, 41);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(427, 190);
this.panel1.TabIndex = 0;
this.panel1.Paint += new
System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
I am startin to build a winform application that uses a lot of the screen. So I put a form (size 2477,1402) and inside a Tab control (location 23,25, size 1883,1244)
However when running the program the tab's right border is too close to the form. In fact no matter how much you enlarge the form, the form size remains the same and if the tab control is enlarged the form hides part of the tab control space.
How can this problem be solved?
The designer code for the controls
private void InitializeComponent()
{
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.panel1 = new System.Windows.Forms.Panel();
this.btn60_1 = new System.Windows.Forms.Button();
this.btn60_2 = new System.Windows.Forms.Button();
this.btn60_3 = new System.Windows.Forms.Button();
this.btn60_4 = new System.Windows.Forms.Button();
this.btn60_5 = new System.Windows.Forms.Button();
this.btn60_6 = new System.Windows.Forms.Button();
this.btn60_7 = new System.Windows.Forms.Button();
this.btn60_8 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Controls.Add(this.tabPage3);
this.tabControl1.Location = new System.Drawing.Point(12, 12);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(1883, 1244);
this.tabControl1.TabIndex = 0;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.panel1);
this.tabPage1.Location = new System.Drawing.Point(4, 28);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(1875, 1212);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "tab1";
this.tabPage1.UseVisualStyleBackColor = true;
//
// tabPage2
//
this.tabPage2.Location = new System.Drawing.Point(4, 28);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(2038, 1140);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "tab2";
this.tabPage2.UseVisualStyleBackColor = true;
//
// tabPage3
//
this.tabPage3.Location = new System.Drawing.Point(4, 28);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
this.tabPage3.Size = new System.Drawing.Size(1875, 1212);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "tab3";
this.tabPage3.UseVisualStyleBackColor = true;
//
// panel1
//
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panel1.Controls.Add(this.button1);
this.panel1.Controls.Add(this.btn60_8);
this.panel1.Controls.Add(this.btn60_7);
this.panel1.Controls.Add(this.btn60_6);
this.panel1.Controls.Add(this.btn60_5);
this.panel1.Controls.Add(this.btn60_4);
this.panel1.Controls.Add(this.btn60_3);
this.panel1.Controls.Add(this.btn60_2);
this.panel1.Controls.Add(this.btn60_1);
this.panel1.Location = new System.Drawing.Point(22, 19);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(522, 466);
this.panel1.TabIndex = 0;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(2455, 1346);
this.Controls.Add(this.tabControl1);
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "My program";
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
Can this answer help you?
private void Form1_Load(object sender, EventArgs e)
{
this.AutoScroll = true;
}
Is there any way to add a System.Windows.Controls.TextBox to GroupBox controls in C#?
I tried the following but it doesn't show up in the groupbox:
public System.Windows.Controls.TextBox textBox6 = new System.Windows.Controls.TextBox();
public System.Windows.Controls.TextBox textBox7 = new System.Windows.Controls.TextBox();
public ElementHost sumtext = new ElementHost();
public ElementHost loctext = new ElementHost();
private void Form1_Load(object sender, EventArgs e)
{
textBox6.Name = "Summary";
textBox7.Name = "Location";
textBox6.FontFamily = new System.Windows.Media.FontFamily("Microsoft Sans Serif");
textBox6.FontSize = 12;
textBox6.SpellCheck.IsEnabled = true;
textBox7.FontFamily = new System.Windows.Media.FontFamily("Microsoft Sans Serif");
textBox7.FontSize = 12;
textBox7.SpellCheck.IsEnabled = true;
groupBox4.Controls.Add(sumtext);
sumtext.Dock = DockStyle.None;
sumtext.Width = 246;
sumtext.Height = 35;
sumtext.Child = textBox6;
sumtext.Location = new Point(3, 33);
sumtext.Visible = true;
sumtext.Enabled = false;
groupBox4.Controls.Add(sumtext);
groupBox4.Controls.Add(loctext);
loctext.Dock = DockStyle.None;
loctext.Width = 246;
loctext.Height = 35;
loctext.Child = textBox7;
loctext.Location = new Point(3, 90);
loctext.Visible = true;
loctext.Enabled = false;
this.Controls.Add(sumtext);
this.Controls.Add(loctext);
}
I need to use System.Windows.Controls.TextBox rather than Form.TextBox as I need it for spell check.
Any help would be greatly appreciated!
I changed the Enabled property of the sumtext, and removed the other box to shorten it:
This code works for me:
public Form1()
{
this.Load += new System.EventHandler(this.Form1_Load);
}
public System.Windows.Controls.TextBox textBox6 = new System.Windows.Controls.TextBox();
public ElementHost sumtext = new ElementHost();
private System.Windows.Forms.GroupBox groupBox4;
private void Form1_Load(object sender, EventArgs e)
{
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.SuspendLayout();
//
// groupBox4
//
this.groupBox4.Location = new System.Drawing.Point(57, 63);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(591, 238);
this.groupBox4.TabIndex = 0;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "groupBox1";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(706, 478);
this.Controls.Add(this.groupBox4);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
textBox6.Name = "Summary";
textBox6.FontFamily = new System.Windows.Media.FontFamily("Microsoft Sans Serif");
textBox6.FontSize = 12;
textBox6.SpellCheck.IsEnabled = true;
groupBox4.Controls.Add(sumtext);
sumtext.Dock = DockStyle.None;
sumtext.Width = 246;
sumtext.Height = 35;
sumtext.Child = textBox6;
sumtext.Location = new Point(3, 33);
sumtext.Visible = true;
sumtext.Enabled = true;
groupBox4.Controls.Add(sumtext);
}
Is this code actually getting called? Has groupbox 4 been added to the form yet?
You should not be adding your ElementHost controls to your Form AND your GroupBox, it appears to be confusing .NET. Keeping your original code exactly as-is but commenting out these two lines makes it work:
//this.Controls.Add(sumtext);
//this.Controls.Add(loctext);
Also... I don't think it's hurting anything, but you don't need to do this twice:
//groupBox4.Controls.Add(sumtext);
In WM6.5 a have a simple form with a webbrowser control. I open a local file and fill this page data to the document.text
1.
On some phones you see the page but no scrollbar?
2.
On my phone and in the simulators I have a scrollbar. If you put your finger on the screen and move vertically you only highlight the text. What I would like is the page to scroll down/up with this touch.
Is there a trick for this? Below is my init and the filling of the html.
public partial class FormLicense : Form
{
bool _CanClose = false;
private const string _html =
"<html><body><br><div style='top:20px;left:50px;border:solid 1px red'><a href='http://www.cnn.com'>CNN</a></div><br><font size='14'>xx</font><a href='http://stackoverflow.com'>stackoverflow</a></body></html>";
public FormLicense()
{
InitializeComponent();
this.Load += new System.EventHandler(this.FormLicense_Load);
this.Closed += new System.EventHandler(this.FormLicense_Closed);
this.Closing += new System.ComponentModel.CancelEventHandler(this.FormLicense_Closing);
this.SuspendLayout();
this.menu1L.Text = "I Accept";
this.menu1R.Text = "Don't Accept";
this.Text = "License";
using (StreamReader sr = new StreamReader(GlobalLicense.FileName, System.Text.Encoding.Default))
{
webBrowser1.DocumentText = sr.ReadToEnd();
}
.....
....
...
..
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menu1L = new System.Windows.Forms.MenuItem();
this.menu1R = new System.Windows.Forms.MenuItem();
this.webBrowser1 = new System.Windows.Forms.WebBrowser();
this.SuspendLayout();
//
// mainMenu1
//
this.mainMenu1.MenuItems.Add(this.menu1L);
this.mainMenu1.MenuItems.Add(this.menu1R);
//
// menu1L
//
this.menu1L.Text = "1L";
this.menu1L.Click += new System.EventHandler(this.menu1L_Click);
//
// menu1R
//
this.menu1R.Text = "1R";
this.menu1R.Click += new System.EventHandler(this.menu1R_Click);
//
// webBrowser1
//
this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill;
this.webBrowser1.Location = new System.Drawing.Point(0, 0);
this.webBrowser1.Name = "webBrowser1";
this.webBrowser1.ScriptErrorsSuppressed = true;
this.webBrowser1.Size = new System.Drawing.Size(240, 268);
//
// FormLicense
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.AutoScroll = true;
this.AutoScrollMargin = new System.Drawing.Size(10, 10);
this.ClientSize = new System.Drawing.Size(240, 268);
this.Controls.Add(this.webBrowser1);
this.Menu = this.mainMenu1;
this.Name = "FormLicense";
this.Text = "FormLicense";
this.ResumeLayout(false);
The scrollbar problem is a bug:
Link