Asked by:
Windows Forms General FAQ

General discussion
-
This material should not be considered as a complete coverage of the frequently asked questions, but it tries to capture the high-level features with some depth in the Windows Forms General areas.
1. TREEVIEW
1.1 How to retain an expanded state after reloading TreeView?
1.2 How to show hierarchical data in TreeView?
1.3 How do I implement Drag and Drop support between two TreeViews?
1.4 How to hide CheckBoxes for child nodes when CheckBoxes is set to true.
2. TEXTBOX
2.1 How do I programmatically position the cursor on a given line and character in a RichTextBox?
2.2 How to save RTF-formatted data from a Windows Forms RTF control to SQL Server?
2.3 How to get the current character’s color of a RichTextBox?
2.4 How to make the scroll smoother in a RichTextBox?
2.5 If a rich text box contains images and text, is it possible to detect when an image is clicked?
2.6 How to make a TextBox only accept digits?
3. COMBOBOX
3.1 How do I setup a ComboBox to bind to a Lookup table?
3.2 How to add a ‘please select’ item toComboBox?
3.3 How to make the drop down part of the combo box wide enough to see all items?
4. LISTBOX
4.1 How to display tooltip on individual items in a ListBox?
4.2 How to add a business object to the item collection of a ListBox and display expected text?
5. MENUSTRIP
5.1 What’s the relationship between MainMenu and MenuStrip?
5.2 How do I disable the MenuStrip's ALT-key action?
5.3 How to set the count of items displayed in a MenuStripItem’sDropDown list?
6. TOOLSTRIP
6.1 How to set the height of ToolStrip and ToolStripItem?
6.2 How to make a ToolStripTextBox hide true text and replace them with '*'?
6.3 Why a ToolStripButton didn’t cause the validation?
7. TABPAGE
7.1 How to put a close button on TabPage header?
7.2 How to hide the header of TabPage?
8. WINDOWS 7 TASKBAR
8.1 How to show two forms on Windows 7 taskbar with different labels?
8.2 How to customize the Windows 7 taskbar thumbnail picture in myapplication?
8.3 How to add an overlay icon for my application in Windows 7 taskbar?
8.4 How to show progress indicator on Windows 7 taskbar for my application?
9. BUTTON
9.1 How to add a shield icon to a button and start a process elevated?- Edited by MSDN FAQ Tuesday, May 4, 2010 3:25 AM
Tuesday, May 4, 2010 1:46 AM
All replies
-
1.1 How to retain an expanded state after reloading TreeView?
That's going to be difficult. Other parent nodes might have been expanded. Capturing the entire state of the tree is tough. The need to refresh the entire tree is odd. You can just refresh the node contents of the existing tree. You could use the TreeNode. Tag property to retain some kind of reference to the source data.
Related Thread:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2203734&SiteID=1Tuesday, May 4, 2010 1:52 AM -
1.2 How to show hierarchical data in TreeView?
First you should create all tree nodes using these records, and then you can use a hash table to store these tree nodes. Finally loop through the hash table and add these tree nodes hierarchically.
RelatedThread:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1774847&SiteID=1Tuesday, May 4, 2010 1:55 AM -
1.3 How do I implement Drag and Drop support between two TreeViews?
In a posting in the Microsoft.Windows.Forms newsgroup, Brian Roder (Microsoft) gives VB.Net code snippets to handle the DragEnter, ItemDrag and DragDrop events that provide a solution to this problem. Here are some sample handlers written in C#.
Code Block
private void treeView2_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
TreeNode newNode;
if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false))
{
Point pt;
TreeNode destinationNode;
pt = treeView2.PointToClient(new Point(e.X, e.Y));
destinationNode = treeView2.GetNodeAt(pt);
newNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");
if (!destinationNode.Equals(newNode))
{
//destinationNode.Nodes.Add(newNode.Clone());
destinationNode.Nodes.Add((TreeNode)newNode.Clone());
destinationNode.Expand();
//Remove original node
newNode.Remove();
}
}
}
private void treeView2_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
e.Effect = DragDropEffects.Move;
}
private void treeView2_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e)
{
DoDragDrop(e.Item, DragDropEffects.Move);
}Tuesday, May 4, 2010 2:01 AM -
1.4 How to hide CheckBoxes for child nodes when CheckBoxes is set to true.
To enable this feature, we should owner draw the tree node. We can set the TreeView.DrawMode property to OwnerDrawAll and handle the DrawNode event. Try something like the following in this handler.
Code Block
private void treeView_DrawNode(object sender, DrawTreeNodeEventArgs e)
{
if (IsThirdLevel(e.Node))
{
Color backColor, foreColor;
if ((e.State&TreeNodeStates.Selected) == TreeNodeStates.Selected)
{
backColor = SystemColors.Highlight;
foreColor = SystemColors.HighlightText;
}
else if ((e.State&TreeNodeStates.Hot) == TreeNodeStates.Hot)
{
backColor = SystemColors.HotTrack;
foreColor = SystemColors.HighlightText;
}
else
{
backColor = e.Node.BackColor;
foreColor = e.Node.ForeColor;
}
using (SolidBrush brush = newSolidBrush(backColor))
{
e.Graphics.FillRectangle(brush, e.Node.Bounds);
}
TextRenderer.DrawText(e.Graphics, e.Node.Text,this.treeView.Font, e.Node.Bounds, foreColor, backColor);
if ((e.State&TreeNodeStates.Focused) == TreeNodeStates.Focused)
{
ControlPaint.DrawFocusRectangle(e.Graphics, e.Node.Bounds,foreColor, backColor);
}
e.DrawDefault = false;
}
else
{
e.DrawDefault = true;
}
}
private static bool IsThirdLevel(TreeNode node)
{
return node.Parent != null&&node.Parent.Parent != null;
}
Related Thread:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1883238&SiteID=1Tuesday, May 4, 2010 2:06 AM -
2.1 How do I programmatically position the cursor on a given line and character in a RichTextBox?
The RichTextBox control contains a Lines array property, one entry for every line. Each line entry has a Length property. With this information, you can position the selection cursor using code such as:
Code Block
private void GoToLineAndColumn(RichTextBoxrtb, int line, int column)
{
rtb.Focus();
if (line < 0 || column < 0)
{
rtb.SelectionStart = 0;
}
else
{
if (line >rtb.Lines.Length - 1)
{
rtb.SelectionStart = rtb.GetFirstCharIndexFromLine(rtb.Lines.Length - 1)
+ rtb.Lines[rtb.Lines.Length - 1].Length;}
else
{
int firstCharIndexOfline = rtb.GetFirstCharIndexFromLine(line);
int textlengthOfline;
textlengthOfline = rtb.Lines[line].Length;
if (column >textlengthOfline)
{
column = textlengthOfline;
rtb.SelectionStart = firstCharIndexOfline + column;
}
}
}Tuesday, May 4, 2010 2:08 AM -
2.2 How to save RTF-formatted data from a Windows Forms RTF control to SQL Server?
In this situation, using a RichTextBox is the easiest way; we can just bind the field to the Rtf property of RichTextBox.
Code Block
Binding bd =new Binding("Rtf", dt, "descs",true);
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2246017&SiteID=1Tuesday, May 4, 2010 2:14 AM -
2.3 How to get the current character’s color of a RichTextBox?
The RichTextBox has provided you a property named SelectionColor; you can use this property to get the current character’s color
Code Block
private void richTextBox1_MouseMove(object sender, MouseEventArgs e)
{
int index = richTextBox1.GetCharIndexFromPosition(e.Location);
richTextBox1.SelectionStart = index;
label1.Text = richTextBox1.SelectionColor.ToString();
}
Related Thread:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2139967&SiteID=1Tuesday, May 4, 2010 2:16 AM -
2.4 How to make the scroll smoother in a RichTextBox?
Try to use two windows API functions, GetScrollPos and PostMessage. The GetScrollPos is used to get the current position of RichTextBox, and the PostMessage is used to place a scroll-down message in the message queue associated with the thread that created the window.
Code Block
<Runtime.InteropServices.DllImport("user32.dll", EntryPoint:="PostMessage")> _
PublicSharedFunction PostMessage(ByValhwndAsInteger, ByValwMsgAsInteger, ByValwParamAsInteger, ByVallParamAsInteger) AsInteger
EndFunction
<Runtime.InteropServices.DllImport("user32.dll", EntryPoint:="GetScrollPos")> _
PublicSharedFunction GetScrollPos(ByValhwndAsInteger, ByValnBarAsInteger) AsInteger
EndFunction
PublicConst WM_VSCROLL AsInteger = 277
PublicConst SB_THUMBPOSITION AsInteger = 4
PublicConst SBS_VERT AsInteger = 1
Private previousPos AsInteger = 0
PrivateSub RTBAutoScroll_Load(ByVal sender AsObject, ByVal e AsEventArgs) HandlesMyBase.Load
Me.RichTextBox1.[Select](0, 0)
Me.RichTextBox1.ScrollToCaret()
Me.Timer1.Interval = 300
AddHandlerMe.Timer1.Tick, AddressOf timer1_Tick
Dim td AsNewDateTime()
Me.Text = td.ToString()
EndSub
PrivateSub timer1_Tick(ByVal sender AsObject, ByVal e AsEventArgs)
Dim currentPos AsInteger = GetScrollPos(CInt(Me.richTextBox1.Handle), SBS_VERT)
If previousPos<>currentPos Or Else currentPos = 0 Then
previousPos = currentPos
PostMessage(CInt(Me.richTextBox1.Handle), WM_VSCROLL, SB_THUMBPOSITION + 65536 * (currentPos + 1), 0)
EndIf
EndSub
PrivateSub Button1_Click_1(ByVal sender AsSystem.Object, ByVal e AsSystem.EventArgs) Handles Button1.Click
If Button1.Text = "Auto Scroll"Then
Button1.Text = "Pause"
Timer1.Enabled = True
Else If Button1.Text = "Pause" Then
Button1.Text = "Auto Scroll"
Timer1.Enabled = False
EndIf
EndSub
Related Thread:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2102412&SiteID=1Tuesday, May 4, 2010 2:20 AM -
2.5 If a rich text box contains images and text, is it possible to detect when an image is clicked?
The Rich Text Format (RTF) Specification says, pictures are destinations, and begin with the \pict control word. We can try to judge the SelectedRtf string to see if this contains the \pict when click on the RichTextBox.
Code Block
this.richTextBox1.MouseClick += new MouseEventHandler(richTextBox1_MouseClick);
void richTextBox1_MouseClick(object sender, MouseEventArgs e)
{
if (this.richTextBox1.SelectedRtf.IndexOf(@"\pict") != -1 &&
this.richTextBox1.SelectionType == RichTextBoxSelectionTypes.Object){
MessageBox.Show("Image has been clicked!");
}
}
Related Thread:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2191267&SiteID=1Tuesday, May 4, 2010 2:23 AM -
2.6 How to make a TextBoxonly accept digits?
You can handle the textbox's KeyPress event and if the char passed in is not digits, mark the events argument as showing that the character has been handled. Below is a derived TextBox that only accepts digits (and control characters such as backspace).
Code Block
public class NumbersOnlyTextBox : TextBox
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
base.OnKeyPress(e);
if (!(char.IsDigit(e.KeyChar) || char.IsControl(e.KeyChar)))
{
e.Handled = true;
}
}
}Tuesday, May 4, 2010 2:24 AM -
3.1 How do I setup a ComboBox to bind to a Lookup table?
A common use of a ComboBox in a data bound application is as a lookup based UI control. From a database perspective, a Lookup control is used to provide the “lookup” values for a foreign key. For example, assume you have a customer table with a “StateID” where the “StateID” is a foreign key into a “States” table. From a UI perspective, you’d like to allow the user to select a State via a ComboBox. To do this, you use Complex Binding to bind the ComboBox to the States table (setting the ComboBox.DisplayMember and ComboBox.ValueMember) and use Simple List Binding to bind the ComboBoxSelectedValue to the Customer “StateID”.
Code Block
Customer cust = new Customer("Joe", "WA");
this.statesCB.DisplayMember = "Name";
this.statesCB.ValueMember = "Code";
this.statesCB.DataSource = statesTable;
this.statesCB.DataBindings.Add("SelectedValue", cust, "StateID", true);
Related Thread:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1753655&SiteID=1Tuesday, May 4, 2010 2:26 AM -
3.2 How to add a ‘please select’ item to ComboBox?
If the ComboBox is not data bound, you can add an item to the item collection.
Code Block
this.comboBox1.Items.Insert(0, "please select");
this.comboBox1.SelectedIndex = 0;
If the ComboBox is data bound, you will need to add this item to the data source
Code Block
Customer cust = new Customer("Joe", null);
DataRow row = statesTable.NewRow();
row["Name"] = " please select";
row["Code"] = DBNull.Value;
statesTable.Rows.Add(row);
this.statesCB.DisplayMember = "Name";
this.statesCB.ValueMember = "Code";
this.statesCB.DataSource = statesTable;
this.statesCB.DataBindings.Add("SelectedValue", cust, "StateID", true);
Related Thread:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1769727&SiteID=1Tuesday, May 4, 2010 2:28 AM -
3.3 How to make the drop down part of the combo box wide enough to see all items?
You can set the DropDownWidth of a combo box to make the combo box dropdown wide enough.
Code Block
string s = "this is a really, really, really, really, really, long string";
Graphics g = Graphics.FromHwnd(this.Handle);
Size size = g.MeasureString(s, comboBox1.Font);
comboBox1.DropDownWidth = Convert.ToInt32(size.Width);
this.comboBox1.Items.Add(s);
Related Thread:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2281333&SiteID=1Tuesday, May 4, 2010 2:29 AM -
4.1 How to display tooltip on individual items in a ListBox?
If you want to display tooltip on individual items in a ListBox, here is a quick easy way. First create a method to handle mouse move events, and then hook it to the MouseMove event of the ListBox. You will also need a ToolTip object as a member variable for the form. The code required to create and update the tooltip is:
Code Block
private void onMouseMove(object sender, MouseEventArgs e)
{
if (sender isListBox)
{
ListBox listBox = (ListBox)sender;
Point point = new Point(e.X, e.Y);
int hoverIndex = listBox.IndexFromPoint(point);
if (hoverIndex>= 0 &&hoverIndex<listBox.Items.Count)
{
tt.SetToolTip(listBox, listBox.Items[hoverIndex].ToString());
}
}
}
Related Thread:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2073944&SiteID=1Tuesday, May 4, 2010 2:32 AM -
4.2 How to add a business object to the item collection of a ListBox and display expected text?
The most common way to achieve this is to set the DiaplayMember to the Proterty name of your business object.
The second way is to use a TypeConverter to convert the business object. You need to custom a TypeConverter and override its ConvertTo method. Check the following sample code.
Code Block
[TypeConverter(typeof(BusinessTypeConvert))]
Class BusinessObject
{
int id;
public int Id
{
get { return id; }
set { id = value; }
}
string name;
public string Name
{
get { return name; }
set { name = value; }
}
}
Class BusinessTypeConvert :TypeConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(string))
{
return ((BusinessObject)value).Name;
}
return base.ConvertTo(context, culture, value, destinationType);
}
}
The third choice is to override the ToString method of your business object and return the expected text in this method. But this is not recommended since ToString method is usually used to return some information about the class.Tuesday, May 4, 2010 2:34 AM -
I want to use two buttons to move items back and forth. For example, ‘L->R’ moves items from left ListBox to right ListBox, ‘R->L’ moves items form right ListBox to left ListBox.
Place two ListBoxes with two buttons between them. One button with Text ‘R->L’, and the other ‘L->R’.
In the L->R click event handler:
Code Block
foreach (int index in listBox1.SelectedIndices)
{
listBox2.Items.Add(listBox1.Items[index]);
listBox1.Items.RemoveAt(index);
}
In the R-L click event handler:
Code Block
foreach (int index in listBox2.SelectedIndices)
{
listBox1.Items.Add(listBox2.Items[index]);
listBox2.Items.RemoveAt(index);
}
For both ListBoxes, the property SelectionMode should be set to MultiSimple. And place several items in one or both of the ListBoxes
Related Thread:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1830319&SiteID=1Tuesday, May 4, 2010 2:38 AM -
5.1 What’s the relationship betweenMainMenu and MenuStrip?
Tuesday, May 4, 2010 2:40 AM -
5.2 How do I disable the MenuStrip's ALT-key action?
Just override the ProcessDialogKey in your form, as:
Code Block
protected override bool ProcessDialogKey(Keys keyData)
{
if ((keyData&Keys.Alt) == Keys.Alt)
{
return true;
}
else
{
return base.ProcessDialogKey(keyData);
}
}Tuesday, May 4, 2010 2:42 AM -
5.3 How to set the count of items displayed in a MenuStripItem’sDropDown list?
If there are too many items in MenuStripItem’s item collection, it will use a lot of space to show these menus. I want to show only eight (or other number) menus. How can I achieve this?
We will need to set the AutoSize of the MenuStripItem’sDropDown portion to false and inputs its height.
Code Block
this.fileToolStripMenuItem.DropDown.AutoSize = false;
this.fileToolStripMenuItem.DropDown.Height = 200;Tuesday, May 4, 2010 2:45 AM -
6.1 How to set the height of ToolStrip and ToolStripItem?
Try to set both ToolStrip and ToolStripItem’s AutoSize to false, and make sure your ToolStrip’s height is greater than all your ToolStripItems. Try something like the following:
Code Block
this.toolStrip1.AutoSize = false;
this.toolStripButton1.AutoSize = false;
this.toolStripButton2.AutoSize = false;
this.toolStripButton3.AutoSize = false;
this.toolStripButton1.Height = 20;
this.toolStripButton2.Height = 40;
this.toolStripButton3.Height = 60;
this.toolStrip1.Height = 65;
Related Thread:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2080536&SiteID=1Tuesday, May 4, 2010 2:46 AM -
6.2 How to make a ToolStripTextBox hide truetext and replace them with '*'?
The ToolStripTextBox actually contains a TextBox and use this TextBox to allow the user to type in. You can get the TextBox hosted in the ToolStripTextBox and set the PasswordChar property.
Code Block
if (this.toolStripTextBox1.Control isTextBox)
{
TextBox tb = this.toolStripTextBox1.Control asTextBox;
tb.PasswordChar = '*';
}
Related Thread:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2042939&SiteID=1Tuesday, May 4, 2010 2:48 AM -
6.3 Why a ToolStripButtondidn’tcause the validation?
By default, toolbars and menus do not need focus when you click on it, thus it does not force validation for controls. A related question is that why it didn’t commit the data to the database when clicking on a toolstrip. To solve this problem, add the following line of code in the click event to force the validation.
Code Block
this.Validate();//this refers to your formTuesday, May 4, 2010 2:49 AM -
7.1 How to put a close button on TabPage header?
We can build a custom TabControl and override its OnDrawItem method in which you paint the "close button", then do the hit testing and close the tab when the "close button" is clicked. The following article demonstrates the idea in more detail:
http://www.codeproject.com/cs/miscctrl/firefoxtabcontrol.aspTuesday, May 4, 2010 2:49 AM -
7.2 How to hidethe header of TabPage?
Add a new class to your project, paste the code shown below and build the project. You can now drop the control from the top of the toolbox onto your form. At design time, the control looks like a regular TabControl. At run-time, you only see the pages. Use the SelectedIndex property to step through the pages.
Code Block
using System;
using System.Windows.Forms;
public class WizardPages : TabControl
{
protected override void WndProc(ref Message m)
{
// Hide tabs by trapping the TCM_ADJUSTRECT message
if (m.Msg == 0x1328 && !DesignMode)
{
m.Result = (IntPtr)1;
}
else
{
base.WndProc(ref m);
}
}
}
Related Thread:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1518961&SiteID=1Tuesday, May 4, 2010 2:52 AM -
8.1 How to showtwo forms on Windows 7 taskbar with different labels?
You can make use of the Microsoft Windows API Code Pack to make this easier.
The basic idea is to call the SetApplicationIdForSpecificWindow method of the TaskbarManager class to set different application IDs for different forms. If two forms have different application IDs, they will be grouped in different labels on the taskbar.TaskbarManager.Instance.SetApplicationIdForSpecificWindow(
subForm.Handle, SubFormAppID);You can find the complete sample in All-In-One Code Framework, the project name is“CSWin7AppID”.
Download: http://1code.codeplex.com/releases/view/41170#DownloadId=108690Tuesday, May 4, 2010 2:53 AM -
8.2 How to customize the Windows 7 taskbar thumbnail picture in my application?
The Microsoft API Code Pack can help on this. Construct a TabbedThumbnail which takes a window handle and a control as parameters, and then call the AddThumbnailPreview method of the TabbedThumbnailManager class to add a thumbnail for the current application.You can also get or remove the thumbnails by calling the GetThumbnailPreview and the RemoveThumbnailPreview method.
Another type of customization onthumbnails is adding buttons to it for custom actions. The corresponding class is ThumbnailToolbarButton. You can call the AddButtons method of the ThumbnailToolbarManager class to add buttons to a thumbnail.
You can find the complete sample in All-In-One Code Framework, the project name is“CSWin7TaskbarThumbnail”.
Tuesday, May 4, 2010 2:55 AM -
8.3 How to add an overlay icon for my application in Windows 7 taskbar?
You can make use of the Microsoft Windows API Code Pack to make this easier. To set an overlay icon, use the TaskbarManager.SetOverlayIcon method.
For example:
// Set the Taskbar Overlay Icon
// TaskbarManager.SetOverlayIcon(Icon icon, string accessibilityText);
TaskbarManager.Instance.SetOverlayIcon(Properties.Resources.Available, "Available icon");Note that before using this feature, we need to check whether the current Windows version supports this feature by using code below:
if (!TaskbarManager.IsPlatformSupported)
{
// If current system doesn’t support this, do something else.
}The All-In-One Code Framework has two samples “CSWin7TaskbarOverlayIcons” and “VBWin7TaskbarOverlayIcons” showing how to do this.
You can download the samples here:
http://1code.codeplex.com/releases/view/41170
Related Threads:
Windows API Code Pack for the Microsoft .NET Framework
http://msdn.microsoft.com/en-us/magazine/dd942846.aspx#id0420051Tuesday, May 4, 2010 2:57 AM -
8.4 How to show progress indicator on Windows 7 taskbar for my application?
You can use the TaskbarManager class available in the Microsoft Windows API Code Pack to do this. The SetProgressState method and the SetProgressValue method modify the state of the taskbar progress bar. There are several states available for applications to use: indeterminate, paused, error and normal.
For example:
// Set the Taskbar button Progress Bar state
// TaskbarManager.SetProgressState(TaskbarProgressBarState state)
TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.Paused);// Set the Taskbar button Progress Bar value
// TaskbarManager.SetProgressValue(int currentValue, int maximumValue)
TaskbarManager.Instance.SetProgressValue(progressBar.Value, MAX_PROGRESSBAR_VALUE);Note that before using this feature, we need to check whether the current Windows version supports this feature by using this code:
if (!TaskbarManager.IsPlatformSupported)
{
// If current system doesn’t support this, do something else.
}The All-In-One Code Framework has two samples “CSWin7TaskbarProgressbar” and “VBWin7TaskbarProgressbar” showing how to do this.
You can download the samples here:
http://1code.codeplex.com/releases/view/41170
Related Threads:
Windows API Code Pack for the Microsoft .NET Framework
http://msdn.microsoft.com/en-us/magazine/dd942846.aspx#id0420051Tuesday, May 4, 2010 2:58 AM -
9.1How to add a shield icon to a button and start a process elevated?
The All-In-One Code Framework has two samples “ CSUACSelfElevation” and “VBUACSelfElevation” demonstrate how to check if the application is running asadministrator. A shield icon will be added to a button on the UI if the application is not run as administrator.
The sample uses WindowsIdentity class to check the account the process is running under. It calls SendMessage to add a shield icon to the button if the process is not running asadministrator. For more information, please refer to ReadMe.txt included in the sample.
You can download the All-In-One Code Framework samples here:
http://1code.codeplex.com/wikipage?title=All-In-One%20Code%20Framework%20Examples&ProjectName=1codeTuesday, May 4, 2010 2:59 AM -
Using the Classic WinForms Designer in WinForms Core
https://github.com/dotnet/winforms/blob/master/Documentation/winforms-designer.md
Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
NuGet BaseConnectionLibrary for database connections.
Saturday, June 1, 2019 5:29 PM