w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
I have two windows forms and when i pressed TAB, the cursor in the form 1 textbox should be placed in form2 textbox.Form1 and form 2 are side by side
Here is a solution: //This form contains textBox1 public class Form1 : Form { public Form1(){ InitializeComponent(); } protected override bool ProcessTabKey(bool forward){ if(textBox1.Focused) form2.FocusText(); base.ProcessTabKey(forward); } Form2 form2 = new Form2(); } //This form contains textBox2 public class Form2 : Form { public Form2(){ InitializeComponent(); } public void FocusText(){ textBox2.Focus(); } } It's not a complete solution but can help you understand the basic mechanism to change the code meeting your requirement.

Categories : C#

Add item in listview in Form1 from textbox in Form2 C#
Try this; private void button1_Click(object sender, EventArgs e) { ListViewItem item = new ListViewItem(textBox1.Text); Form1 f1 = new Form(); f1.listView1.Items.Add(item); }

Categories : C#

Passing the values of my TextBox from Form1 to form2 by clicking button
Try this: private void btnAddReceipt_Click(object sender, EventArgs e) { this.Hide(); var Ticket = new frmCustomerTicket(); Ticket.CustomerID = txtCustNo.Text; Ticket.Show(); } Upate Remove the using block it will cause the Form2 element to dispose as soon as it falls out of scope.

Categories : C#

I know how to send information from Form1 to Form2, but how do I edit it and send it back if the data is contained in a List in Form1?
When you make new Form1() inside Form2, you are creating a completely new Form1 with no filled data. It's not the original Form1 that called Form2. So, what you need is to set that Form1 to the original, not to a new one: public partial class Form2 : Form { public Form2() { InitializeComponent(); } public Form1 fm1; //just declare, but let Form1 do the assign job. //the rest of the code... } And in Form 1 for (int i = c; i <= 0; i++) { if (lstCart.GetSelected(i)) { Form2 fm2 = new Form2(); fm2.productNameTextBox.Text = myBasket[i].ProductName; fm2.quantityTextBox.Text = Convert.ToString(myBasket[i].Quantity); fm2.latestPriceTextBox.Text = Convert.ToString(myBasket[i].LatestPrice); //here is the news:

Categories : C#

Why form1 also closes form2 whenever form1 is closed?
I'm not so sure about your case .. but I think you can make your switchBoard_F form as your main form. When you call login_F form you can hide the main form .. So when the user input right password you just close login_F form .. and if they didn't you may close both of them ..

Categories : Dotnet

Edit Two Form2's from Form1
Like this: var theForm: TForm; myForm2: Form2; begin for theForm in Screen.Forms do begin if theForm is Form2 then begin myForm2 := Form2(theForm); //do something with myForm2... end; end; end; Or this: var theForm: TForm; myForm2: Form2; I: Integer; begin for I := 0 to Screen.Forms.Count-1 do begin theForm := Screen.Forms[I]; if theForm is Form2 then begin myForm2 := Form2(theForm); //do something with myForm2... end; end; end; Depending on your Delphi version.

Categories : Delphi

C# Updating Form1 when closing Form2
I think your problem is you are creating a new instance of Form1 instead of passing in a reference to the original Form1. If you pass in a reference to the original Form1; you will be updating that instances. Not a new one. See this post for similar problem to what I think your experiencing. refreshing treeview component from other form

Categories : Dotnet

Codeigniter submitting form1 form2 on form_open
Change your nested submit element to <input type="submit" name="form2_button" value="form2_submit"/> Then, you can check the inner form submission using if(isset($_POST["form2_button"]))` or in codeigniter you can input->post('form2_button') Having a form nested under another form is not a valid HTML/XHTML. But you can try the follow code above.

Categories : Codeigniter

Adding panels from Form2 to form1(MainForm)
You're creating a new instance of Form1 here: Form1 f1 = new Form1(); But you want to add your panels on the existing one, so use: Form f1 = Application.OpenForms['formname'];

Categories : C#

How to interact with Listbox from Form2 throught thread from Form1
Here's an example... Public Class Form1 Private f2 As New Form2 Private Delegate Sub AddItemDelegate(ByVal item As String) Private Delegate Function GetTextboxTextDelegate(ByVal TB As TextBox) As String Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim testthread As New Threading.Thread(AddressOf testira) testthread.Start() End Sub Sub testira() Dim item As String = GetTextboxText(TextBox1) AddItem(item) End Sub Private Function GetTextboxText(ByVal TB As TextBox) As String If TB.InvokeRequired Then Return TB.Invoke(New GetTextboxTextDelegate(AddressOf GetTextboxText), New Object() {TB}) Else Return TB.Text End If

Categories : Vb.Net

Enable/disable an ordinary button on Form2 from Form1
LoL just had to declare globaly an instance of Kalibracio, open it and then access it's properties from all other methods. I tried this approach at first, but my problem was that I was creating and instance locally, then I had to create another one in some other method because I couldn't address the former one created locally, and ofc it didn't work...

Categories : Forms

datagridview in form1 automatic refresh after insert from form2
Some thoughs on the code. Unless I'm missing something, the snippet does the insert (that's OK) and then reads all the data back, but does nothing with the result, so Form1 in fact never realizes that something happened at all. What you need to do is some how notify Form1 that Form2 has finished with its insert, and pass back the data. The grid should have some sort of data source from where it takes the rows to display, and you need to add the newly created data from Form2 there. The best way I can think of is to create an event on Form2 that Form1 will suscribe to, passing all the data needed to recreate the record. First create the event handler data: public class InsertCompleteEventArgs : EventArgs { public string zakce {get;set;} public string zname {get;set;} /*other

Categories : C#

Change the datatable in Form1 from Form2 Visual Basic
Try to create new module in your project then declare your datatable in there .. Public DataGridTable As DataTable Don't declare public in class form .. So you can call in every form class .. Public Class AddForm Public Sub Add_Click(sender As Object, e As EventArgs) Handles AddButton.Click DataGridTable.Rows.Add(NameBox(), VersionBox(), "Compile", LocationBox(), CompileBox()) End Sub End Class

Categories : Vb.Net

how can i control listview located in form1 from form2 to refresh it
Maybe need refresh. public void RefeshListView() { this.listView1.BeginUpdate(); MessageBox.Show("s");//this shows! only: !?!?!? listView1.Visible = false; listView1.Height = 222; listView1.EndUpdate(); listView2.Clear(); listView2.refresh(); }

Categories : C#

Update textboxes in Form1 on updating the datagridview from Form2
You are creating a new instance of Form1 that has nothing to do with the original instance (and perhaps has not the same data displayed) so your update code acts on this form instance (hidden by the way) and doesn't change anything in the original instance. The simplest method to resolve this problem is passing the instance of Form1 to the constructor of Form2, save this instance inside Form2 and call the update using this saved instance In form1.cs Form2 f = new Form2(this); f.Show(); In form2.cs Form1 _callingInstance; public Form2(Form1 caller) { _callingInstance = caller; } private void button1_Click(object sender, EventArgs e) { _callingInstance.UpDateData(dt); this.Close(); } A slightly better approach to this InterForm Communication problem is through the crea

Categories : C#

I've set a value on a class property on Form1, but when I tried to access it on Form2 it doesn't return a value, why?
I have a piece of paper, and I write my name on it. If I then get a completely different piece of paper, my name is not automatically on it. It is the same here - there are two User objects here, completely unrelated. If you want the name from the first, you need to pass that User object to the second form.

Categories : C#

Open form2 from two buttons (form1) and matching button that was clicked
You should create a) a new constructor, which takes button reference ( better name, or whatever You can put into their unused property "Tag" to identify them ) or b ) a public method, which You call before opening the form ( but after instantiating it ) or c) a property in form2, which can take anything You would decide to use as "thing to diffentiate. Ok ?

Categories : C#

Windows Forms Textbox Enter key
If I understood correctly you want to call method when users presses Enter while typing anything in textbox? Then you have to use KeyUp event of TextBox like this: public Simple() { Text = "Server Command Line"; ... TextBox txt = new TextBox (); txt.Location = new Point (20, Size.Height - 70); txt.Size = new Size (600, 30); txt.KeyUp += TextBoxKeyUp; //here we attach the event txt.Parent = this; Button button = new Button(); ... } private void TextBoxKeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { //Do something e.Handled = true; } }

Categories : C#

Windows Forms Textbox is uneditable by accident
You shouldn't use a while loop to detect specific key events. Your while loop is holding up the form. I suggest you check out these articles on Events and Event handlers for Windows forms. http://msdn.microsoft.com/en-us/library/dacysss4.aspx

Categories : C#

ApiController acess values textBox Windows Forms
Your PegarCoordenadas method is static but Controls like edtLatitudeGMS belong to a certain instance of a form. Everything you reference in a static method needs to be static itself. So your code isn't valid. When you made PegarCoordenadas static because you don't have a concrete reference to a FormPrincipal instance at the spot were you want to call it then you took the wrong direction to solve this. You must have concrete reference to such an instance. When you create FormPrincipal store the reference somewhere (maybe in your GPSController) and make it accessable in the Posicao method.

Categories : C#

cannot convert from 'const char [11]' to 'System::Windows::Forms::TextBox ^'
phoneNum is a a TextBox^, not a "string" of some form. You'll want to compare against the Text property of this control, not the control itself. You likely need: if (phoneNum->Text == "555555555") {

Categories : Visual C++

Transfer numbers in textbox to labels in another form c# windows forms
You have to pass your Form1 reference to Show method. And then use `thi btnconvert.Enabled = true; Exchange_Rate frm = new Exchange_Rate(); frm.Show(this); and then: private void btnok_Click(object sender, EventArgs e) { double exchange; exchange = Double.Parse(txtcurrent.Text); var frm = (Form1)this.Owner; frm.PassValue(txtcurrent.Text); this.Close(); }

Categories : C#

Value of type 'String' cannot be converted to 'System.Windows.Forms.Textbox'?
Search.TextBox1 = value You just tried to assign the TextBox1 variable to hold a string instead of a textbox. That doesn't make any sense. Instead, you want to set the text being displayed in the textbox, by setting its Text property.

Categories : Vb.Net

C# Using Property of TextBox from Form2
First off, Form1 really shouldn't know anything about the internal controls of Form2. The textbox shouldn't be public at all. Instead create a property on Form2 that exposes the information that you need: public class Form2 : Form { private Textbox textbox1; public string SomeText //TODO replace with meaningful name { get { return textbox1.Text; } } } Next, at some point you're presumably creating an instance of your form to show it. You can access the property through that instance: Form2 childForm = new Form2(); childForm.ShowDialog(); MessageBox.Show(childForm.SomeText); In some situations you may also need to store the instance of Form2 as an instance field of Form1 rather than just a local variable: private Form2 childForm = new Form2(); private v

Categories : C#

I need a textbox value in form 1 to be inserted into form2 as a string in the html level in asp
Here's how you can do this: Webform1 Markup: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="SOTest1.WebForm1" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="Your text: "> </asp:Label><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="GO" OnClick="Button1_Click" /> </div> </form> </body> </html> Webform1 Code: using System; namespace SOTe

Categories : C#

TextBox Autocomplete Up and Down key Cant Select item in list
Why not put it in Form Load event instead of Text Changed: private void Form1_Load(object sender, EventArgs e) { try { SqlDataReader datareader = qu.GetValue("English_Short"); AutoCompleteStringCollection local = new AutoCompleteStringCollection(); if (datareader.HasRows == true) { while (datareader.Read()) local.Add(datareader["English_Short"].ToString()); } txt_Name.AutoCompleteMode = AutoCompleteMode.Suggest; txt_Name.AutoCompleteSource = AutoCompleteSource.CustomSource; txt_Name.AutoCompleteCustomSource = local; } catch (Exception ex) { Messag

Categories : C#

SharePoint Custom Display and edit list item forms
Go on just like what SharePoint does in order to show item data. Both display forms and edit forms start by reading the query string value "ID": string strItemId = Request.QueryString["ID"]; You can add some validations to check if the query parameter exists and if it is actually a number and if an item actually exists in that list with the given ID. Finally, store valid itemId in an integer variable and retrieve the item as follows: SPListItem item = myList.GetItemByID(itemId); Continue to fill in the controls (labels in case of display forms and text boxes, drop downs, ... in case of edit forms) with item fields as below: txtTitle.Text = item["Title"] + String.Empty; You will then need to set item fields for the edit form on save button click event and then update the item.

Categories : Sharepoint

Link Item in List View in textbox in other form
Don't close the first form until you have gathered the data you want, instead wait to close the form like this: 'View Technicians Daily Task Code Private Sub Button3_Click(ByVal sender As System.Object, ByVal e _ As System.EventArgs) Handles Button3.Click frm_pe.Show() frm_pe.txtid.Text = ListView1.CheckedItems(0).SubItems(0).Text frm_pe.txtlname.Text = ListView1.CheckedItems(0).SubItems(1).Text frm_pe.txtfname.Text = ListView1.CheckedItems(0).SubItems(2).Text frm_pe.txtmi.Text = ListView1.CheckedItems(0).SubItems(3).Text Me.Close End Sub OR You can just hide the form, like this: Me.Hide Note: Hiding the form will still keep the form in memory, but make it invisible to the user.

Categories : Vb.Net

How to copy the content of a data grid view in form1 to another data grid view in form2 in c#
private void CopyAll(DataGridView from, DataGridView to) { if (to.Columns.Count == 0) { foreach (DataGridViewColumn dgvc in from.Columns) { to.Columns.Add(dgvc.Name, dgvc.HeaderText); } } to.Rows.Clear(); foreach(DataGridViewRow dgvr in from.Rows) { List<string> cells = new List<string>(); foreach(DataGridViewCell dgvc in dgvr.Cells) { cells.Add(dgvc.Value.ToString()); } to.Rows.Add(cells.ToArray()); } }

Categories : C#

Adding new item to a listItem (drop down list) on google Forms using apps script
Use getChoices() to get a copy of the existing list and append the choice. choices = listItem.getChoices(); choices.push(listItem.createChoice('black')); listitem.setChoices(choices);

Categories : Google Apps Script

call a Windows Forms method from outside Windows Forms (from int WINAPI WinMain)
it looks like 'Application::Run(myInterface);' does not return until it is done doing what it has to do, which is nothing It's not nothing. Application::Run most importantly starts the Windows event message pump. This event loop is what keeps your application alive and running. Application::Run will return only when this loop exits. The event loop generally exits when you close your main form or try to close the process from task manager etc. Which means by the time Application::Run returns, your myInterface form is already closed - which makes rest of the code below it useless. You can move that code to something like Form's Load event.

Categories : C++

Remove duplicate items from list if certain properties match and get the top item based on some ordering
The simplest way to group on multiple properties is to use an anonymous type: var groups = users.GroupBy(user => new { Name, Type, SubType, }); This works because the implementation of anonymous types is such that they override the Equals method to compare the values of each member of the type, and also overrides the GetHashCode method to make it a composite hash of the hashes of all of the values of the object. If you just created a new named type you would need to handle all of that yourself, which is simply tedious.

Categories : C#

Adding Sharepoint List Item to Windows form list
Completely untested, made fresh while drinking morning coffee. Good luck! var list = siteWeb.Lists.TryGetList(listName); if (list == null) { return; } var items = list.GetItems(query); var countOfItems = items.Count; if (countOfItems == 0) { return; } var listItemFieldObjects = items.Cast<SPListItem>().Select(item => item[1]); foreach (var item in listItemFieldObjects) { var listViewItem = new ListViewItem("Object's value"); listView.BeginUpdate(); listViewItem.SubItems.Add(item.ToString()); listView.Items.Add(listViewItem); listView.EndUpdate(); }

Categories : Sharepoint

Accessing form2 List Elements to mainform
You could declare a public list in Form2, and add the items in question to this list once you are done/closing form2. This will then be accessable from Form1 is Form1 has a reference to the Form2 object. So in Form2 you could have something like public partial class Form2 : Form { public List<string> f2List = new List<string>(); private void button1_Click(object sender, EventArgs e) { f2List.Add(f2List.Count.ToString()); } and then from Form1 you could try public partial class Form1 : Form { private void button1_Click(object sender, EventArgs e) { Form2 f2 = new Form2(); f2.ShowDialog(); List<string> f1List = f2.f2List; } EDIT See action for adding items to List in Form2 so they are available in Form1

Categories : C#

How to show inner content in list item outside of that list item without being covered up by descending list items
You must set the z-index of the clicked 'li' higher and in return the former clicked 'li' back. Here is the example: fiddle And here the script: var oldli; $('li').click( function(){ $(oldli).toggleClass('displayNone displayBlock'); $(oldli).css("z-index","1"); $(this).toggleClass('displayBlock displayNone'); $(this).css("z-index","5"); oldli=$(this); } );

Categories : Javascript

WPF How to bind list to itemscontrol with each item being paired to a customcontrol and bound to the ith item in list
The DataContext for each UI item in the ItemsControl will automatically be assigned to the corresponding Data Item in the source Collection. Therefore this is valid and will work: <ItemsControl x:Name ="Signalviewer_Control" ItemsSource="{Binding Source = {StaticResource signal_data}, Path = list_of_signals}"> <ItemsControl.ItemTemplate> <DataTemplate> <wpfExp:SignalViewer Signal="{Binding}"/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl>

Categories : Wpf

Python list manipulation: Add an item to a string element to make it a 2 item list
Modify a[0]: >>> a = ['spam', 'eggs', 100, 1234] >>> a[0] = [a[0], 'Devon'] >>> a [['spam', 'Devon'], 'eggs', 100, 1234] For your updated question: >>> items = ['devon', 'baloney'] >>> a = ['spam', 'eggs', 100, 1234] >>> a[0] = [a[0]] + items >>> a [['spam', 'devon', 'baloney'], 'eggs', 100, 1234] If you're not sure about the position of 'spam' then use a list comprehension: >>> a = ['spam', 'eggs', 100, 1234] >>> [item if item != 'spam' else [item, 'devon'] for item in a] [['spam', 'devon'], 'eggs', 100, 1234]

Categories : Python

Way to not duplicate codes between "models.py" and "forms.py"?
A ModelForm can have fields that are model-bound and unbound. You can also override the label attribute for a model field without having to re-define the field in your form: class RegistrationForm(forms.ModelForm): class Meta: model = MyUser error_css_class = 'error' required_css_class = 'required' def __init__(self, *args, **kwargs): super(RegistrationForm, self).__init__(*args, **kwargs) self.fields['full_name'].label = _("Full Name") password2 = forms.CharField( widget=forms.PasswordInput, label=_("Password (again)"), ) Although, I don't see where you're providing labels for any of your model fields differently in your form. You can always add the label attribute at the model level too: class MyUser(AbstractBaseUser

Categories : Django

How do I pass a string value from a TextBox between Forms?
You're dealing with two completely separate instances of Form2. Your first instance, which the user used to login, is inaccessible from within Form1. The instance of Form2 that you created inside the button click event in Form1 only has the initial value of string.Empty stored in strVar. To get it up and working, I'd change your Main method to pass the value you need into the constructor of Form1: ... if (fLogin.ShowDialog() == DialogResult.OK) { Application.Run(new Form1(fLogin.strVar)); } ... And then modify the constructor of Form1 (which I don't see in your snippet) to accept that argument: private string userName = string.Empty; public Form1(string userName) { InitializeComponent(); this.userName = userName; } Get rid of the separate instance of Form2 inside the b

Categories : C#

How to rotate windows forms in every 20 secs using timer in windows application?
On a 20 second timer you can call 'BringToFront' on each form. http://msdn.microsoft.com/en-us/library/system.windows.forms.control.bringtofront.aspx

Categories : Vb.Net



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.