im trying to work with the menustrip and i have the helpToolStripMenuItem_Click may someone help me the code on how to put the documentation i.e if i click help a new window show appear with documentation like this picture i capture from a vlc help button
any ideas this is my empty code
private void helpToolStripMenuItem_Click(object sender, EventArgs e)
{
}
Make form (for example with name frm_Help) with RichTextBox and Button
In Richtextbox add all text (read this Richtextbox)
In button event click add
{
Close();
}
Somewhere where you want to show this form add
{
frm_Help frm=new frm_Help;
frm.ShowDialog();
}
To get the same result as in the image you posted, you need to create a new form, put a WebBrowser control to it and load the HTML page with the documentation to this control in the form's initialization code:
public HelpForm()
{
InitializeComponent();
string text = System.IO.File.ReadAllText(#"Docs\readme.html");
webBrowser1.DocumentText = text;
}
Here, the code reads HTML from the readme.html file located in the Docs subfolder of the folder where the EXE file is located.
You should create new form, containing all the text you want in it and in helpToolStripMenuItem_Click you should create new instance of that form and show it (as a dialog maybe)
Create a new form or add AboutBox and add RichTextbox control.
Related
I have a question : I need to show pdf documents without askink what to open to the user. It needs to be matched with a unique id. Let's say I have a product_ID=55435, and I need to open the 55435.pdf by automatically in a windows form.
Thank you !
I suggest you follow the steps below:
(1) You can add ActiveX controls provided by Adobe to the toolbox.
Method: Right click on the blank of the toolbox=>choose items=>COM Components=>check AdobePDF Reader=>OK
As the picture shows:
(2) You can drag the Adobe PDF Reader control to the form, create a button button1, and add button events.
The button event code is as follows:
private void button1_Click(object sender, EventArgs e)
{
string filename =; // Example: filename = #"F:\SoftWare\PdfFile\55435.pdf";
axAcroPDF1.LoadFile(filename);
}
Running result:
I have created a ToolStripMenuItem called "About". Underneath "About", I have a submenu called "About MatchingGame". Upon clicking on "About MatchingGame", I want it to display a dialog box. In that box, I want to be able to show an image and some text (one field on top of another).
So far, I have this code for the about menu:
private void aboutMatchingGameToolStripMenuItem_Click(object sender, EventArgs e)
{
Form dlg1 = new Form();
dlg1.ShowDialog();
}
This gives me the form dialog that I need, though it is still blank. Is there a way to get the dialog box to show up when looking at the design so that I can add a picture box to it? When I click on "About MatchingGame" from the design file, it just lets me change the text and does not open the form dialog to let me put anything in it. How can I get the dialog form to display what I need (an image and a text field)? I have tried added open file dialog to the source code, but I could not get that to work (and it doesn't solve the problem of the text). Any ideas?
Yes, create a new Form and add it to your project. Give it a name like "MyForm". Then you can change the form in the designer.
Instead of doing Form dlg1 = new Form();, do MyForm dlg1 = new MyForm();. The rest of your code can be the same.
I have C# code linked to an xaml file that builds a GUI. In the GUI, when I click on an option, the photo appears, as I want. However, I can't figure out how to make it so the user has the option to close the photo. Here's my C# code:
public void help_click(object sender, RoutedEventArgs e)
{
Image img;
img = new Image();
Uri diagram = new Uri(#"pack://application:,,,/PTDGUI;component/Content/Icons/controlmap.png", UriKind.RelativeOrAbsolute);
img.Source = new BitmapImage(diagram);
canvasSpace.Children.Add(img);
}
Image is not based on Control. You may require to customize for this behavior by either writing custom control or trapping any other control events to close this image.
This discsussion(stackoverflow) explains both the options I've mentioned, should help in understand and implementing what you rquired.
you can use the same help button for both, initially button will display "Help", When user clicks help, load the image and change the button text to "Close" and toggle it back to "Help" when users clicks again.
if(button.Text ="Help")
{
---load image
button.Text = "Close";
}
else
{
--Clear image
button.Text ="Help"
}
you may also use bool flag instead of checking text.
I have application under test with report preview. I want to click on control, which will be activated. For clicking on this control on report preview, I get coordinates of this control relatively to page. For getting coordinates of control I use CanvasItem.Bounds property and convert this coordinates to pixels. But how to get coordinates of page relatively to Viewer on which this page with controls is located?
Or maybe somebody knows how to get CanvasItem coordinates relatively to Viewer control?
Thank you for any help!!!
Your issue has already been replied on the C1Forums:
http://our.componentone.com/groups/topic/is-it-possible-to-get-coordinates-of-page-relatively-to-viewer-control-datadyna/
Regards,
Mohita
CanvasItem is an internal class and I would not recommend you to use it in your application. If you are simply looking to trap the click on a control then I think a better and simple approach would be to make use of TextBoxes with Hyperlink set. You can then handle the "Hyperlink" event of the viewer control to detect which control was clicked on the basis of its hyperlink value.
So I will list the steps:
Set Hyperlink property for the textboxes (say "a" for TextBox1 and "b" for TextBox2)
Capture the "Hyperlink" event of the viewer like this:
private void viewer1_HyperLink(object sender, GrapeCity.ActiveReports.Viewer.Win.HyperLinkEventArgs e)
{
if (e.HyperLink == "a")
{
MessageBox.Show("TextBox1 Clicked");
}
else
{
MessageBox.Show("TextBox2 Clicked");
}
}
Finally assign the report to the viewer:
private void Form1_Load(object sender, EventArgs e)
{
SectionReport1 rpt = new SectionReport1();
viewer1.LoadDocument(rpt);
viewer1.UseHyperlinkSettings = false;
}
I have a windows form and i dont want to make any other windows forms just one windows form and different user controls how can i change between user controls for example hide one and show the other user control programmatically ?
private void Btt_info_Click(object sender, EventArgs e)
{
Frm_Main frm_main = new Frm_Main();
frm_main.Controls["panel1"].Controls.Clear();
UC_Info uc_info = new UC_Info();
frm_main.Controls["panel1"].Controls.Add(uc_info);
}
i added this but it doesnt work
Add a container control (if I remember correctly, there's a containers section in the toolbox?), like a panel. Create usercontrols for what you want to dynamically switch around. So make like a 'HomePage' usercontrol and a 'LoginPage' usercontrol. Dynamically add the usercontrol that you want to display to the container. WHen you want, remove it from the container and add a different usercontrol:
Panel myPanel = new Panel();
LoginPage ctlLoginPage = new LoginPage();
HomePage ctlHomePage = new HomePage();
//add the loginpage to the panel first
myPanel.Controls.Add(ctlLoginPage);
...do stuff...
//remove whatever control is currently in the Panel
myPanel.Controls.Clear();
//add the other control, the HomePage control instead now
myPanel.Controls.Add(ctlHomePage);
..do other stuff...
I usually do it this way so you leave your form itself open to add common controls and stuff that might be shared between your different 'pages'.
EDIT: Note that I normally would add the panel in the designer and not create it dynamically in the code. This was just an example.
EDIT: The interaction between your mainform and usercontrols can be handled in a few different ways, and I am not saying that any of these is the correct method.
You create a static property for your Panel on the Mainform, so that
you can always access it to swap your controls around.
In this example I'll also add a static method for it
enum PanelControlsEnum {HomePage, LoginPage};
public static Panel MyContainerPanel {get;set;}
public static void SwitchPanelControls(PanelControlsEnum selControl){
..put your switch panels code here..
}
Then inside your usercontrol you call a predefined method, something like:
MainForm.SwitchPanelControls(PanelControlsEnum.HomePage);
Another method is to bind the button click event on your mainform
instead of inside the form.
Like This:
HomePage ctlHomePage = new HomePage();
ctlHomePage.Click += MyClickEvent;
myPanel.Controls.Add(ctlHomePage)
...
private void MyClickEvent(object sender, RoutedEventArgs e)
{
..switch user control code here...
}
Create a method that returns a UserControl object. Then put conditions in that method as to which control you want to load at a specific condition and then in your main form code.
UserControl control = GetControlFromMyMethod();
form1.Controls.Add(control);
where 'control' is the returned control from your method.
To remove the existing one you have to loop through the form1.Controls and find out the control and call 'Remove'.
Update:
Mike C has a better idea of adding a panel and loading your desired control on the panel as then it's easy to remove your control and you then don't have to loop through the forms controls to find it and then remove it.
Try this:
this.Controls.Clear();
usercontrol load = new usercontrol ();
this.Controls.Add(load);
load.Show();
you could try this it will definitely help you as it did helped me a lot it short and straight to the point hope that will help