I searched myself through for about 1 hour only to realise that I might be the biggest beginner, but since everybody must have been at that point in a time, i hope for your patience.
My question: i have an empty Winform which is opened after a button is pressed on a custom created outlook properties button.
the button code:
private void FensterOeffnen(object sender, IRibbonControl control, bool pressed)
{
EinstellungenFenster fenster = new EinstellungenFenster();
fenster.ShowDialog();
}
the Winform code:
public partial class EinstellungenFenster : Form
{
public EinstellungenFenster()
{
InitializeComponent();
Text = "Outlook Add-in Einstellungen";
}
}
the Reason i need a checkbox:
i want to implement a popup (Debug so to say) window on each and every method that i have on my Outlook Add-in if the button is checked, so that if the code stopps working at a certain point after deployment, i can still easily tell where the problem is.
Thanks a lot!
Open the toolbox on vs by going to view and toolbox then expand all windows forms and scroll down to check-box and drag it on to the form.
and then implement the checked procedure by adding on the button clicked
if (Checkboxname.Checked = true)
{
// Do Stuff when checked
}
hope this helps
Related
i am making a flat GUI in windows forms.. i know i cant just ignore and leave tab indexing and i have included it. when i am using tab in my program to select control,a black outline appears on controls(as in this pic). what i want is to remove this outlining when i mouse-click anywhere because it seems Ugly if i am not using my keyboard.
how can i remove this outline on flat button
can you suggest me how can i achieve this target?
Try hiding the focus cue by creating your own button:
public class ButtonEx : Button {
protected override bool ShowFocusCues {
get {
return false;
}
}
}
I'm currently working on a "Settings" screen for a project and want to implement a view similar to that found in Visual Studio, where there is a TreeView with a list of options and clicking on one of these options will load a UserControl in an adjacent panel in the same form. I am using a SplitContainer to group these two controls.
I thought that the Load event for the User Control would be triggered when it was displayed in the panel, but this is not the case. I also tried to trigger the Enter event but it still did not work so I tried to call a function when the form was initialized using the following method.
ViewSecurity newViewSecurity = new ViewSecurity(Globals._connectionString);
// This creates a new instance of the ViewSecurity form from within the TreeView.
And this is the code in the initializing function for the User Control
public ViewSecurity(string _cString)
{
InitializeComponent();
connectionString = _cString;
MessageBox.Show("Test");
populateData();
}
This method does not work either - the MessageBox does not show up and the function populateData() isn't called either. Any advice on how I could achieve what I am trying to do?
Thanks in advance!
I've been trying to find a way to disable a form, and put another form in front of it to act as a receiving party for my update command from SQL Server. My only problem is... The appearance of my main form, seems to be simple, and I'd rather keep it that way. I got two exhibits, since I can't post pictures in this state yet... But I'll update so more will understand.
Exhibit 1: My medical records form has several buttons, containing the INSERT, UPDATE, DELETE, View via Crystal Report, Print, Search and the Back buttons. There's also a listview object placed that occupies most of the form.
Exhibit 2: My UPDATE form is consisted of 7 textboxes: 6 containing basic info, and one containing the full name of the user which is by default, read-only. Two buttons, UPDATE and Back are in the form as well. Labels are placed above the basic info textboxes to signal the user's information to be entered.
Here's my question: How will I disable all buttons and the listview (which is the form of Exhibit 1), and place Exhibit 2 over it, WITHOUT hiding Exhibit 1?
To clarify, Exhibit 1 cannot be accessed as long as Exhibit 2 is in place, once it's open (which is my goal). I was trying to find a way to put the Update form over the medical records form, but to no luck, I keep seeing the Medical Records form clickable once the two are open at the same time. Please help me out... I'm just a student who's getting the hang of things in Visual Studio 2010, but I thought of asking just to know if anyone knows.
To those who would answer... thank you. :) It's my first post... so please be patient...
Here is an example which uses a main form mainForm and a button cb_update to open a second form updateForm. Upon opening, the 2nd form places itself over the 1st form and disables all controls of the 1st form. When it is closed it hides itself and re-enables all controls of the 1st form.
Note: both forms have a reference to each other, so they can work with all (public) parts of the other form. (If you need to you can always make a Control public!). One reference is kept from opening, the other is handed in the constructor..
En- or Disabling the controls is done recursively using the Controls collection and the fact that a Form is a Control, too. Here is code for the 1st form:
public partial class mainForm : Form
{
updateForm Uform;
private void cb_update_Click(object sender, EventArgs e)
{
if (Uform == null) Uform = new updateForm(this);
Uform.Show();
}
}
And here the 2nd:
public partial class updateForm : Form
{
mainForm main_Form;
public updateForm(mainForm main)
{
InitializeComponent();
main_Form = main;
}
private void updateForm_Shown(object sender, EventArgs e)
{
this.Size = main_Form.Size;
this.Location = main_Form.Location;
//*1*
setControlState(main_Form, false);
}
private void cb_back_Click(object sender, EventArgs e)
{
setControlState(main_Form, true);
this.Hide();
}
private void updateForm_FormClosing(object sender, FormClosingEventArgs e)
{
setControlState(main_Form, true);
this.Hide();
}
//*2*
public void setControlState(Control Ctl, bool enabled)
{
//*3*
foreach (Control c in Ctl.Controls) setControlState(c, enabled);
Ctl.Enabled = enabled;
//*4*
}
}
Edit: This code assumes that all Controls on the main_form are initially enabled. If that is not the case an exceptions list will take care of that, adding four lines of code:
exceptions.Clear(); //*1*
List<Control> exceptions = new List<Control>(); //*2*
if (!enabled && !Ctl.Enabled) exceptions.Add(Ctl); //*3*
if (enabled && exceptions.Contains(Ctl)) Ctl.Enabled = false; //*4*
Edit 2: I am still not quite sure, what you mean by "Place Exhibit 2 over it, WITHOUT hiding Exhibit 1". If you mean "place it above without hiding it" 1 or 2 lines of the code would be a little different.. Please explain!
I am sure this is a really simple question as I am new to VSTO. I have developed an outlook 2010 separate form region which has its own button on the ribbon bar. It all works fine except I cannot for the life of me work out how to implement a cancel button on the form region. I have spent hours looking for code examples but cant find one. All I want is for the cancel button to close the form region but i cannot work out how to hook up the button to do this.
Regards
Martin Lines
foreach (Microsoft.Office.Tools.Outlook.IFormRegion formRegion in Globals.FormRegions)
{
if (formRegion is FormRegion1)
{
FormRegion1 formRegion1 = (FormRegion1)formRegion;
formRegion1.OutlookFormRegion.Visible = false;
}
}
Currently i am working on a word Addin, where i have added controls to the ribbon dynamically. Now, I need to catch the dynamic button "btnSubmit" and based on the condition i need to enable/disable the button.
when the document is opened for the first time it should be enabled and Once the Button is clicked it should be disabled.
This should be done on a boolean condition. Any help would be greatly appreciated.
thanks,
KSR Prasad
It is possible through RibbonXML using the getEnabled event.
Ribbon XML:
<button id="button1" onAction="button1_Click" getEnabled="button1_EnabledChanged" />
Code:
public void button1_Click(Office.IRibbonControl control)
{
if (control.Id == "button1")
{
// your code
clicked = true; // a boolean variable
}
}
public bool button1_EnabledChanged(Office.IRibbonControl control)
{
if (control.Id == "button1")
return !clicked;
}
If you've already created the button, just create a regional scope WITHEVENTS variable to hold it in, assign it, then react to the click event to disable the button (the button object has an enabled property).
Private WithEvents _MyButton As Ribbon.RibbonButton
....
Set _MyButton = {the just created button}
then handle the click event
My preference for this type of issue is to use RibbonXml rather than the designer.
A really simple option would be have a Dictionary which you can then store in the ribbon callback class. If you wanted a nicer option, VSTO Contrib (http://vstocontrib.codeplex.com/) allows you to create a 'viewmodel' per document quite easily, then you simply can bind the button enabled to a property on the viewmodel.
More info on ribbon xml: http://jake.ginnivan.net/vsto-ribbon-designer-in-depth
More info on vsto contrib and how it can help you: http://jake.ginnivan.net/vsto-contrib/ribbon-factory
Cheers,
Jake