Search Results

Search found 422 results on 17 pages for 'componentmodel'.

Page 10/17 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • TabControl winform c#

    - by Steve
    Hi, Does anyone know why my tabcontrol will not display on this form? Have a feeling it maybe something simple but at the moment i just get a blank form. Thanks using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace test_project_3 { public partial class TabTest : Form { public TabTest() { InitializeComponent(); WebBrowser WB = new WebBrowser(); WB.Navigate("www.google.com"); TabControl tc = new TabControl(); tc.Dock = DockStyle.Fill; tc.Show(); TabPage tp = new TabPage(); tp.Text = "test"; tp.Show(); tp.Controls.Add(WB); tc.TabPages.Add(tp); } } }

    Read the article

  • serialport error

    - by I__
    i have the following code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Threading; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public class ThreadWork { public static void DoWork() { serialPort1.Open(); serialPort1.Write("AT+CMGF=1\r\n"); //Thread.Sleep(500); serialPort1.Write("AT+CNMI=2,2\r\n"); //Thread.Sleep(500); serialPort1.Write("AT+CSCA=\"+4790002100\"\r\n"); //Thread.Sleep(500); serialPort1.DataReceived += serialPort1_DataReceived_1; } } private void Form1_Load(object sender, EventArgs e) { ThreadStart myThreadDelegate = new ThreadStart(ThreadWork.DoWork); Thread myThread = new Thread(myThreadDelegate); myThread.Start(); } private void serialPort1_DataReceived_1(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { string response = serialPort1.ReadLine(); this.BeginInvoke(new MethodInvoker(() => textBox1.AppendText(response + "\r\n"))); } } } and for all the serialport1 lines i am getting this error: Error 1 An object reference is required for the non-static field, method, or property 'WindowsFormsApplication1.Form1.serialPort1' C:\Users\alexluvsdanielle\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.cs 23 17 WindowsFormsApplication1 what am i doing wrong?

    Read the article

  • Am I using Settings in .NET correctly?

    - by Sergio Tapia
    Here's what I'm doing. I have three properties: MomsBackground, DadsBackground and ChosenBackground. When Momsbackground is selected in the program, I set the ChosenBackground string according to what item the user has clicked (either "Mom" or "Dad"). Then on Form_Load() I use a switch case for the ChosenBackground string and according to that select This.BackgroundColor to MomsBackground or DadsBackground. Code below: Am I using this as it was intended? Sorry, codes there now. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void momToolStripMenuItem_Click(object sender, EventArgs e) { this.BackColor = Properties.Settings.Default.MomFormColor; Properties.Settings.Default.SelectedTheme = "Mom"; Properties.Settings.Default.Save(); } private void dadToolStripMenuItem_Click(object sender, EventArgs e) { this.BackColor = Properties.Settings.Default.DadFormColor; Properties.Settings.Default.SelectedTheme = "Dad"; Properties.Settings.Default.Save(); } private void Form1_Load(object sender, EventArgs e) { switch (Properties.Settings.Default.SelectedTheme) { case "Mom": this.BackColor = Properties.Settings.Default.MomFormColor; break; case "Dad": this.BackColor = Properties.Settings.Default.DadFormColor; break; default: break; } } } }

    Read the article

  • Open the Word Application from a button on a web page

    - by Andrea
    I'm developing a proof of concept web application: A web page with a button that opens the Word Application installed on the user's PC. I'm stuck with a C# project in Visual Studio 2008 Express (Windows XP client, LAMP server). I've followed the Writing an ActiveX Control in .NET tutorial and after some tuning it worked fine. Then I added my button for opening Word. The problem is that I can reference the Microsoft.Office.Interop.Word from the project, but I'm not able to access it from the web page. The error says "That assembly does not allow partially trusted callers". I've read a lot about security in .NET, but I'm totally lost now. Disclaimer: I'm into .NET since 4 days ago. I've tried to work around this issue but I cannot see the light!! I don't even know if it will ever be possible! using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using Word = Microsoft.Office.Interop.Word; using System.IO; using System.Security.Permissions; using System.Security; [assembly: AllowPartiallyTrustedCallers] namespace OfficeAutomation { public partial class UserControl1 : UserControl { public UserControl1() { InitializeComponent(); } private void openWord_Click(object sender, EventArgs e) { try { Word.Application Word_App = null; Word_App = new Word.Application(); Word_App.Visible = true; } catch (Exception exc) { MessageBox.Show("Can't open Word application (" + exc.ToString() + ")"); } } } }

    Read the article

  • Serialize Forms into memory

    - by serhio
    Background: In a desktop MDI application we have a lot of forms. Task: Save the controls contents of closed forms(textbox texts, checkbox checks etc). Limitations: A saved form for (DB/Windows) user? For (DB/Windows) group of users? Both variants may be possible. Question: a) What is the best way? b) if I want do not use files, how to serialize the form into a MemoryStream and then recuperate it if the opening form was been once opened and serialized? StartingPoint: Implemented a form that implements ISerializable. Deserialize the form on opening, serialize onclosing: Public Sub GetObjectData(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext) Implements System.Runtime.Serialization.ISerializable.GetObjectData info.AddValue("tbxExportFolder", tbxExportFolder.Text, GetType(String)) info.AddValue("cbxCheckAliasUnicity", cbxCheckAliasUnicity.Checked, GetType(Boolean)) End Sub Public Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext) Me.New() Me.tbxExportFolder.Text = info.GetString("tbxExportFolder") Me.cbxCheckAliasUnicity.Checked = info.GetBoolean("cbxCheckAliasUnicity") End Sub Private Sub SerializeMe() Dim binFormatter As New Formatters.Binary.BinaryFormatter Dim fileStream As New FileStream(SerializedFilename, FileMode.Create) Try binFormatter.Serialize(fileStream, Me) Catch Throw Finally fileStream.Close() End Try End Sub Protected Overrides Sub OnClosing(ByVal e As System.ComponentModel.CancelEventArgs) SerializeMe() MyBase.OnClosing(e) End Sub

    Read the article

  • get html content of a page with Silverlight

    - by Yustme
    Hi, I'm trying to get the html content of a page using silverlight. Webresponse and request classes don't work in silverlight. I did some googling and I found something. This is what i tried: public partial class MainPage : UserControl { string result; WebClient client; public MainPage() { InitializeComponent(); this.result = string.Empty; this.client = new WebClient(); this.client.DownloadStringCompleted += ClientDownloadStringCompleted; } private void btn1_Click(object sender, RoutedEventArgs e) { string url = "http://www.nu.nl/feeds/rss/algemeen.rss"; this.client.DownloadStringAsync(new Uri(url, UriKind.Absolute)); if (this.result != string.Empty && this.result != null) { this.txbSummery.Text = this.result; } } private void ClientDownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { this.result = e.Result; //handle the response. } } It gives me a runtime error after pressing the button: Microsoft JScript runtime error: Unhandled Error in Silverlight Application An exception occurred during the operation, making the result invalid. Check InnerException for exception details. at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary() at System.Net.DownloadStringCompletedEventArgs.get_Result() at JWTG.MainPage.ClientDownloadStringCompleted(Object sender, DownloadStringCompletedEventArgs e) at System.Net.WebClient.OnDownloadStringCompleted(DownloadStringCompletedEventArgs e) at System.Net.WebClient.DownloadStringOperationCompleted(Object arg) I've tried numerous things but all failed. What am i missing? Or does anyone know how i could achieve this in a different way? Thanks in advance!

    Read the article

  • .Net 2.0 ServiceController.GetServices()

    - by Miles
    I've got a website that has windows authentication enable on it. From a page in the website, the users have the ability to start a service that does some stuff with the database. It works fine for me to start the service because I'm a local admin on the server. But I just had a user test it and they can't get the service started. My question is: Does anyone know of a way to get a list of services on a specified computer by name using a different windows account than the one they are currently logged in with? I really don't want to add all the users that need to start the service into a windows group and set them all to a local admin on my IIS server..... Here's some of the code I've got: public static ServiceControllerStatus FindService() { ServiceControllerStatus status = ServiceControllerStatus.Stopped; try { string machineName = ConfigurationManager.AppSettings["ServiceMachineName"]; ServiceController[] services = ServiceController.GetServices(machineName); string serviceName = ConfigurationManager.AppSettings["ServiceName"].ToLower(); foreach (ServiceController service in services) { if (service.ServiceName.ToLower() == serviceName) { status = service.Status; break; } } } catch(Exception ex) { status = ServiceControllerStatus.Stopped; SaveError(ex, "Utilities - FindService()"); } return status; } My exception comes from the second line in the try block. Here's the error: System.InvalidOperationException: Cannot open Service Control Manager on computer 'server.domain.com'. This operation might require other privileges. --- System.ComponentModel.Win32Exception: Access is denied --- End of inner exception stack trace --- at System.ServiceProcess.ServiceController.GetDataBaseHandleWithAccess(String machineName, Int32 serviceControlManaqerAccess) at System.ServiceProcess.ServiceController.GetServicesOfType(String machineName, Int32 serviceType) at TelemarketingWebSite.Utilities.StartService() Thanks for the help/info

    Read the article

  • c# sending sms from computer

    - by I__
    i have this code: private SerialPort port = new SerialPort("COM1", 115200, Parity.None, 8, StopBits.One); Console.WriteLine("Incoming Data:"); port.WriteTimeout = 5000; port.ReadTimeout = 5000; // Attach a method to be called when there is data waiting in the port's buffer port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived); // Begin communications port.Open(); #region PhoneSMSSetup port.Write("AT+CMGF=1\r\n"); Thread.Sleep(500); port.Write("AT+CNMI=2,2\r\n"); Thread.Sleep(500); port.Write("AT+CSCA=\"+4790002100\"\r\n"); Thread.Sleep(500); #endregion // Enter an application loop which keeps this thread alive Application.Run(); i got it from here: http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_22832563.html i have a new winforms empty application: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } } } can you please tell me: where exactly would i paste the code? how do i get the code to run? i am sending AT COMMANDS to my cell phone that is attached to the computer

    Read the article

  • how to edit a text message ( sms ) as it arrives in windows mobile 6 using managed code

    - by x86shadow
    I want to make an application to be installed on two pocket PCs and send Encrypted text messages and receive and decrypt them on the other device. I already made an application that gets special text messages ( starting with !farenc! ) and I know how to Encrypt/Decrypt the messages as well but I don't know how to edit a text message as it's arrive ( for decryption ). please help. thanks in advance and sorry for my bad English using System; using System.Linq; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Microsoft.WindowsMobile; using Microsoft.WindowsMobile.PocketOutlook; using Microsoft.WindowsMobile.PocketOutlook.MessageInterception; namespace SMSDECRYPT { public partial class Form1 : Form { MessageInterceptor _SMSCatcher = new MessageInterceptor(InterceptionAction.Notify, true); MessageCondition _SMSFilter = new MessageCondition(); public Form1() { InitializeComponent(); _SMSFilter.Property = MessageProperty.Body; _SMSFilter.ComparisonType = MessagePropertyComparisonType.StartsWith; _SMSFilter.CaseSensitive = true; _SMSFilter.ComparisonValue = "!farenc!"; _SMSCatcher.MessageCondition = _SMSFilter; _SMSCatcher.MessageReceived += new MessageInterceptorEventHandler(_SMSCatcher_MessageReceived); } private void Form1_Load(object sender, EventArgs e) { //... } void _SMSCatcher_MessageReceived(object sender, MessageInterceptorEventArgs e) { SmsMessage mySMS = (SmsMessage)e.Message; string sms = mySMS.Body.ToString(); sms = sms.Substring(8); //Decryption //... //Update the received message and replace it with the decrypted text //!!!HELP!!! } } }

    Read the article

  • Visual Studio IntelliSense - IHideObjectMembers trick doesn't work. What am I missing?

    - by stakx
    The IHideObjectMembers trick can be used e.g. in fluent interface implementations to hide System.Object members from IntelliSense. (If you don't know this trick, you can read up on it via the above link; I'm just repeating the interface's usual declaration here:) using System; using System.ComponentModel; [EditorBrowsable(EditorBrowsableState.Never)] public interface IHideObjectMembers { [EditorBrowsable(EditorBrowsableState.Never)] Type GetType(); [EditorBrowsable(EditorBrowsableState.Never)] int GetHashCode(); [EditorBrowsable(EditorBrowsableState.Never)] string ToString(); [EditorBrowsable(EditorBrowsableState.Never)] bool Equals(object obj); } I'm now supposed to be able to hide System.Object members on another type as follows: public class SomeClass : IHideObjectMembers { ... } or: public class ISomeInterface : IHideObjectMembers { ... } I tried this in both VS 2008 Express and VS 2008 Standard. However, no members are hidden from IntelliSense at all. I have used the EditorBrowsableAttribute in different projects and it always worked well; however, it doesn't work in this particular scenario. If things had worked as expected, I would only have seen the SomeMethodTwo method. Am I missing something?

    Read the article

  • Can't access resource from Generic.xaml within the Custom Control constructor.

    - by myermian
    I'm not sure why this is doing this, but I can't access the resource from within my constructor. XTabItem.cs using System; using System.ComponentModel; using System.Windows; using System.Windows.Controls; using System.Windows.Media; namespace MyStuff { public class XTabItem : TabItem { public static readonly DependencyProperty XTabItemNormalBackgroundProperty; /// <summary> /// Visual Property: Normal Background /// </summary> [Description("Determines the visibility of the close button."), Category("XTabItem Visual")] public Brush XTabItemNormalBackground { get { return (Brush)GetValue(XTabItemNormalBackgroundProperty); } set { SetValue(XTabItemNormalBackgroundProperty, value); } } static XTabItem() { DefaultStyleKeyProperty.OverrideMetadata(typeof(XTabItem), new FrameworkPropertyMetadata(typeof(XTabItem))); XTabItemNormalBackgroundProperty = DependencyProperty.Register("XTabItemNormalBackground", typeof(Brush), typeof(XTabItem), new UIPropertyMetadata(null)); } public XTabItem() { //XTabItemNormalBackground = (Brush)this.TryFindResource("XTabItemNormalBackgroundBrush"); //THIS DOES NOT WORK?? } public override void OnApplyTemplate() { base.OnApplyTemplate(); } } } Generic.xaml <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:MyStuff" xmlns:con="clr-namespace:MyStuff.Converters" > <SolidColorBrush x:Key="XTabItemNormalBackgroundBrush" Color="BlueViolet" /> <Style TargetType="{x:Type local:XTabItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:XTabItem}"> <!-- CONTENT TEMPLATE --> <Grid SnapsToDevicePixels="True"> <Border x:Name="_Border" Background="{Binding Path=XTabItemNormalBackground, RelativeSource={RelativeSource Mode=TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,1,0"> ... </Border> </Grid> </Style> </ResourceDictionary>

    Read the article

  • How to get the coordinates of an image mouse click in the event handler?

    - by Edward Tanguay
    In the following WPF app, I have an Image in a ContentControl. When the user clicks on the image, how can I get the x/y coordinates of where the mouse clicked on the image? XAML: <Window x:Class="TestClick828374.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <StackPanel Margin="10"> <ContentControl Content="{Binding TheImage}" MouseDown="ContentControl_MouseDown"/> </StackPanel> </Window> Code-Behind: using System; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.Imaging; using System.ComponentModel; namespace TestClick828374 { public partial class Window1 : Window, INotifyPropertyChanged { #region ViewModelProperty: TheImage private Image _theImage; public Image TheImage { get { return _theImage; } set { _theImage = value; OnPropertyChanged("TheImage"); } } #endregion public Window1() { InitializeComponent(); DataContext = this; TheImage = new Image(); TheImage.Source = new BitmapImage(new Uri(@"c:\test\rectangle.png")); TheImage.Stretch = Stretch.None; TheImage.HorizontalAlignment = HorizontalAlignment.Left; } #region INotifiedProperty Block public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } #endregion private void ContentControl_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { //how to get the coordinates of the mouse click here on the image? } } }

    Read the article

  • serial port does not exist in current context: c#

    - by I__
    here's the code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Threading; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public class ThreadWork { private static SerialPort serialPort1; public static void DoWork() { serialPort1.Open(); serialPort1.Write("AT+CMGF=1\r\n"); //Thread.Sleep(500); serialPort1.Write("AT+CNMI=2,2\r\n"); //Thread.Sleep(500); serialPort1.Write("AT+CSCA=\"+4790002100\"\r\n"); //Thread.Sleep(500); serialPort1.DataReceived += serialPort1_DataReceived_1; } } private void Form1_Load(object sender, EventArgs e) { ThreadStart myThreadDelegate = new ThreadStart(ThreadWork.DoWork); Thread myThread = new Thread(myThreadDelegate); myThread.Start(); } private void serialPort1_DataReceived_1(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { string response = serialPort1.ReadLine(); this.BeginInvoke(new MethodInvoker(() => textBox1.AppendText(response + "\r\n"))); } } } and i get an error on this line: string response = serialPort1.ReadLine(); it says:: Error 1 The name 'serialPort1' does not exist in the current context C:\Users\alexluvsdanielle\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.cs 44 31 WindowsFormsApplication1 what am i doing wrong?

    Read the article

  • How can I make the WebBrowser control navigate to a specific webpage?

    - by tee
    How can I make the code when run the code it go to samsung.com private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e) { webBrowser1.Navigate("www.samsung.com"); } Please correct it when run program it go to samsung.com using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using mshtml; namespace webhiglight { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e) { webBrowser1.Navigate("www.samsung.com"); } private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { if (webBrowser1.Document != null) { IHTMLDocument2 document = webBrowser1.Document.DomDocument as IHTMLDocument2; if (document != null) { IHTMLSelectionObject currentSelection = document.selection; IHTMLTxtRange range = currentSelection.createRange() as IHTMLTxtRange; if (range != null) { const String search = "ant"; if (range.findText(search, search.Length, 2)) { range.select(); } } } } } } }

    Read the article

  • Visual Studio 2008 Installer, Custom Action. Breakpoint not firing.

    - by Snake
    Hi, I've got an installer with a custom action project. I want the action to fire at install. The action fires, when I write something to the event log, it works perfectly. But I really need to debug the file since the action is quite complicated. So I've got the following installer class: namespace InstallerActions { using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Configuration.Install; using System.Diagnostics; using System.IO; [RunInstaller(true)] // ReSharper disable UnusedMember.Global public partial class DatabaseInstallerAction : Installer // ReSharper restore UnusedMember.Global { public DatabaseInstallerAction() { InitializeComponent(); } public override void Install(IDictionary stateSaver) { base.Install(stateSaver); System.Diagnostics.Debugger.Launch(); System.Diagnostics.Debugger.Break(); // none of these work Foo(); } private static void Foo() { } } } The installer just finalizes without warning me, it doesn't break, it doesn't ask me to attach a debugger. I've tried debug and release mode. Am I missing something? Thanks -Snake

    Read the article

  • How to properly use Object Contexts in Entity Framework using BackgroundWorker

    - by OffApps Cory
    Good day, I am developing using Entity Framework and WPF, and I am encountering some errors and I don't know why. When saving a record (using a BackgroundWorker), I set the entities change tracker to nothing (null), attach the record to a new disposable context, save it, detach, and dispose of the context. Saving a record fires and event in the MainViewModel of the program that the other ViewModels (including the one that is saving) need to refresh their entities to reflect changes. Private Sub _saveRecordWorker_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles _saveRecordWorker.DoWork Using MyContext As New RVShippingEntities Dim MyShipment = CType(ShipmentRecord, IEntityWithChangeTracker) MyShipment.SetChangeTracker(Nothing) MyContext.Attach(MyShipment) MyContext.Detach(ShipmentRecord) End Using End Sub The Refresh background worker is similar, but it has a Do While block to keep it from interfering with the save worker (which doesn't appear to be working; hence the post). When I save (and it subsequently refreshes) I get the following error: The calling thread cannot access this object because a different thread owns it. I thought that with the DoWhile block, it would wait (and when i step through it does) until the save thread finished, and all would be good. But it would seem that something (either the main thread or the save thread) is still doing something that is interfering. Is there a better way of doing this? Am I doing it is a goofy kludgey fashion? Any help would be appreciated. (Apparently Firefox recognized kludgey as a word. Interesting)

    Read the article

  • how can i handle calculator buutons in c# window form program

    - by sama
    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace lab8ass1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button11_Click(object sender, EventArgs e) { textBox1.Text += "."; } private void btnone_Click(object sender, EventArgs e) { textBox1.Text += "1"; } private void btnrwo_Click(object sender, EventArgs e) { textBox1.Text += "2"; } private void btnthree_Click(object sender, EventArgs e) { textBox1.Text += "3"; } private void btnfour_Click(object sender, EventArgs e) { textBox1.Text += "4"; } private void btnfive_Click(object sender, EventArgs e) { textBox1.Text += "5"; } private void btnsix_Click(object sender, EventArgs e) { textBox1.Text += "6"; } private void btnseven_Click(object sender, EventArgs e) { textBox1.Text += "7"; } private void btneight_Click(object sender, EventArgs e) { textBox1.Text += "8"; } private void btnnine_Click(object sender, EventArgs e) { textBox1.Text += "9"; } private void btnzero_Click(object sender, EventArgs e) { textBox1.Text += "0"; } string s1,s; private void btnplus_Click(object sender, EventArgs e) { s1 = textBox1.Text; textBox1.Text = ""; s = textBox1.Text; //textBox1.Text } private void btnequal_Click(object sender, EventArgs e) { } } } here my code how can i handle calculator buutons

    Read the article

  • How can I edit an incoming text message (sms) as it arrives in windows mobile 6 using managed code

    - by x86shadow
    I want to make an application for pocket PCs to send and receive Encrypted text messages. I have already made an application that gets special text messages ( starting with !farenc! ) and I know how to Encrypt/Decrypt the messages as well. The problem is that I don't know how to edit a text message after it's arrived (for decryption). See code below for more info. using System; using System.Linq; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Microsoft.WindowsMobile; using Microsoft.WindowsMobile.PocketOutlook; using Microsoft.WindowsMobile.PocketOutlook.MessageInterception; namespace SMSDECRYPT { public partial class Form1 : Form { MessageInterceptor _SMSCatcher = new MessageInterceptor(InterceptionAction.Notify, true); MessageCondition _SMSFilter = new MessageCondition(); public Form1() { InitializeComponent(); _SMSFilter.Property = MessageProperty.Body; _SMSFilter.ComparisonType = MessagePropertyComparisonType.StartsWith; _SMSFilter.CaseSensitive = true; _SMSFilter.ComparisonValue = "!farenc!"; _SMSCatcher.MessageCondition = _SMSFilter; _SMSCatcher.MessageReceived += new MessageInterceptorEventHandler(_SMSCatcher_MessageReceived); } private void Form1_Load(object sender, EventArgs e) { //... } void _SMSCatcher_MessageReceived(object sender, MessageInterceptorEventArgs e) { SmsMessage mySMS = (SmsMessage)e.Message; string sms = mySMS.Body.ToString(); sms = sms.Substring(8); //Decryption //... //Update the received message and replace it with the decrypted text //!!!HELP!!! } } }

    Read the article

  • Getting the time interval between typing characters in a TextBox, in C#

    - by sama
    I have a form that has a TextBox and a Label and I want to get the time of the first character entered in the textbox. Then if the user enters more than ten charcaters, the time between the first charcter entered and the tenth charcter entered is displayed in the label. Can any one help me please? I'm using C# Here is the code but I cannot complete it and I have many things that need to be written but I don't know how to continue. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Threading; namespace n { public partial class Form1 : Form { int count=0; public Form1() { InitializeComponent(); } private void textBox1_TextChanged(object sender, EventArgs e) { DateTime t1 = new DateTime();// the time when entering the first charcter DateTime t2 = new DateTime(); t2 = System.DateTime.Now - t1; int index = textBox1.SelectionStart; Point p; p = textBox1.GetPositionFromCharIndex(index); Thread t = new Thread(counttext); t.Start(); label1.Text = "t2"; } private int counttext() { while (textBox1.Text.Length < 10) { count++; if (count == 10) return count; } } } }

    Read the article

  • PhotoChooserTask + Navigation.

    - by user562405
    I taken two Images & added event (MouseButtonDown) for them. When first image handles event to open Gallery. Second image handles events for open camera. When user has choosed his image from the gallery, I want to navigate to next page. Its navigates. But before completing navigation process, it displays MainPage & then moves toward next page. I didnt want to display the MainPage once user chooses the image from the gallery. Plz help. Thanks in advance. public partial class MainPage : PhoneApplicationPage { PhotoChooserTask objPhotoChooser; CameraCaptureTask cameraCaptureTask; // Constructor public MainPage() { InitializeComponent(); objPhotoChooser = new PhotoChooserTask(); objPhotoChooser.Completed += new EventHandler<PhotoResult>(objPhotoChooser_Completed); cameraCaptureTask = new CameraCaptureTask(); cameraCaptureTask.Completed += new EventHandler<PhotoResult>(objCameraCapture_Completed); } void objPhotoChooser_Completed(object sender, PhotoResult e) { if (e != null && e.TaskResult == TaskResult.OK) { //Take JPEG stream and decode into a WriteableBitmap object App.CapturedImage = PictureDecoder.DecodeJpeg(e.ChosenPhoto); //Delay navigation until the first navigated event NavigationService.Navigated += new NavigatedEventHandler(navigateCompleted); } } void navigateCompleted(object sender, EventArgs e) { //Do the delayed navigation from the main page this.NavigationService.Navigate(new Uri("/ImageViewer.xaml", UriKind.RelativeOrAbsolute)); NavigationService.Navigated -= new NavigatedEventHandler(navigateCompleted); } void objCameraCapture_Completed(object sender, PhotoResult e) { if (e.TaskResult == TaskResult.OK) { //Take JPEG stream and decode into a WriteableBitmap object App.CapturedImage = PictureDecoder.DecodeJpeg(e.ChosenPhoto); //Delay navigation until the first navigated event NavigationService.Navigated += new NavigatedEventHandler(navigateCompleted); } } protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e) { e.Cancel = true; } private void image1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { objPhotoChooser.Show(); } private void image2_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { cameraCaptureTask.Show(); }

    Read the article

  • Preselection in the save dialog (c#)

    - by FullmetalBoy
    Goal: Save a notepad file in the computer. (C#) Problem: I don't know how to make a preselection as "TXT Files(*.txt)" in the "Save as type:" when save dialog display? // Fullmetalboy using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace Labb2_application { public partial class MainForm : Form { public MainForm() { InitializeComponent(); } private void mnuFileOpen_Click(object sender, EventArgs e) { OpenFileDialog fDialog = new OpenFileDialog(); fDialog.Title = "Öppna"; fDialog.Filter = "Text files|*.txt"; fDialog.InitialDirectory = @"C:\Windows"; fDialog.ShowHelp = true; DialogResult result = fDialog.ShowDialog(); // Show the dialog and get result. if (result == DialogResult.OK) { string fileAdress = fDialog.FileName; try { string textContent = File.ReadAllText(fileAdress); rtxtDisplay.Text = textContent; } catch (IOException) { } } // If syntax } private void mnuFileSave_Click(object sender, EventArgs e) { saveAsFileDialog.ShowDialog(); } private void mnuFileSaveAs_Click(object sender, EventArgs e) { saveAsFileDialog.Filter = "Text files|*.txt"; saveAsFileDialog.ShowDialog(); } private void mnuFileExit_Click(object sender, EventArgs e) { Application.Exit(); } private void saveAsFileDialog_FileOk(object sender, CancelEventArgs e) { string fileNameAddress = saveAsFileDialog.FileName; File.WriteAllText(fileNameAddress, rtxtDisplay.Text); } } // Partial Class }

    Read the article

  • Windows Forms application C# | Sending Tweet

    - by Andrew Craswell
    I've been able to get my Twitter web app working just fine, but I've recently decided to add Tweeting functionality from a Windows Form, but I'm having no luck sending tweets. No errors are thrown or anything. Mind looking over my code? using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using TweetSharp; namespace TwitterAdvirtiser { public partial class Form1 : Form { private string cKey = "xxx"; private string cSecret = "xxx"; private string oToken = "xxx"; private string aToken = "xxx"; public Form1() { InitializeComponent(); OnStart(); } private void OnStart() { //Authenticate with Twitter TwitterService service = new TwitterService(cKey, cSecret); service.AuthenticateWith(oToken, aToken); service.SendTweet("testing"); } } } It seems like I'm authenticating just fine, I can walk through debug mode and see all my details in the TwitterUser structure, and yet my tweets never show up on my feed. Whats up? By the way, I'm using Visual Studios 2010, and .NET 4.0. I have verified that the oToken and aToken strings have my developer tokens.

    Read the article

  • threading and getting COM port of attached phone

    - by I__
    i have the following code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Threading; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public class ThreadWork { public static void DoWork() { } } private void Form1_Load(object sender, EventArgs e) { ThreadStart myThreadDelegate = new ThreadStart(ThreadWork.DoWork); Thread myThread = new Thread(myThreadDelegate); myThread.Start(); // Begin communications serialPort1.Open(); serialPort1.Write("AT+CMGF=1\r\n"); //Thread.Sleep(500); serialPort1.Write("AT+CNMI=2,2\r\n"); //Thread.Sleep(500); serialPort1.Write("AT+CSCA=\"+4790002100\"\r\n"); //Thread.Sleep(500); } private void serialPort1_DataReceived_1(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { string response = serialPort1.ReadLine(); this.BeginInvoke(new MethodInvoker(() => textBox1.AppendText(response + "\r\n"))); } } } what i am trying to do is send AT COMMANDS to my phone which is attached to the computer through USB how do i know how to configure the properties of the serial port? (like which COM is the phone on [it's attached through USB], what about baudrate and databits?) when i run the program nothing really happens, i would like to send AT COMMANDS to my phone and the textbox is there to receive the response from my phone this is my first time using threads. am i using them correctly? what is the purpose of it in the current example? is it to just have a delay between send a response? what am i doing wrong?

    Read the article

  • Detect whether or not a specific attribute was valid on the model

    - by Sir Code-A-Lot
    Having created my own validation attribute deriving from System.ComponentModel.DataAnnotations.ValidationAttribute, I wish to be able to detect from my controller, whether or not that specific attribute was valid on the model. My setup: public class MyModel { [Required] [CustomValidation] [SomeOtherValidation] public string SomeProperty { get; set; } } public class CustomValidationAttribute : ValidationAttribute { public override bool IsValid(object value) { // Custom validation logic here } } Now, how do I detect from the controller whether validation of CustomValidationAttribute succeeded or not? I have been looking at the Exception property of ModelError in the ModelState, but I have no way of adding a custom exception to it from my CustomValidationAttribute. Right now I have resorted to checking for a specific error message in the ModelState: public ActionResult PostModel(MyModel model) { if(ModelState.Where(i => i.Value.Errors.Where((e => e.ErrorMessage == CustomValidationAttribute.SharedMessage)).Any()).Any()) DoSomeCustomStuff(); // The rest of the action here } And changed my CustomValidationAttribute to: public class CustomValidationAttribute : ValidationAttribute { public static string SharedMessage = "CustomValidationAttribute error"; public override bool IsValid(object value) { ErrorMessage = SharedMessage; // Custom validation logic here } } I don't like relying on string matching, and this way the ErrorMessage property is kind of misused. What are my options?

    Read the article

  • winUserControl in VS2010 - properties are not visible in designer

    - by mj82
    I have a problem with (I suppose) my Visual Studio 2010 Express environment: when I design my own UserControl, in Properties grid I can't see public properties of that control. They are however visible in the project, that reference this control. As it's Express Edition, I create new empty project, then add new UserControl to it. Then, for a test, I put following code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; namespace Project1 { public partial class UserControl1 : UserControl { private int myNumber; [Browsable(true)] public int MyNumber { get { return myNumber; } set { myNumber = value; } } public UserControl1() { InitializeComponent(); } } } In VS 2008, as I remember, that should be enogh to show MyNumber property in Properties grid, even without [Browsable(true)] attribute. In VS 2010 however, when I double click UserControl1.cs in Solution Explorer and look in Properties, I don't see MyNumber. When I reference and use this control in another project, there is an access to it's properties. I've tried to competly reinstall VS 2010 environment, including SP1, but with no success. Do you have any idea what can be wrong? By the way: none of these attributes are working, either: [Browsable(true)] [EditorBrowsable(EditorBrowsableState.Always)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] [Bindable(true)] Best regards, Marcin

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >