C# :: Class Not Getting Textbox Values
Sep 13, 2014
I am not able to get my textbox values in my Register class for my calcTotal method. However, if I convert the text to a double in the Form class and then pass that to my function it will work. But I don't understand why I need to do it like that.
namespace CashRegister {
class Register : Form1 {
public double getItemPrice(string str) {
double item = 0;
item = Convert.ToDouble(str);
return item;
[Code] .....
View 2 Replies
ADVERTISEMENT
Jul 28, 2014
I need to display values from my array that I get from my textbox 1 into my textbox 2 with the following format:
char[0] "whatever" char[2]
void Button1Click(object sender, EventArgs e) {
string text = BIRTH_DAYW2.Text;
string [] split = text.Split(new char[] {'/'});
for(int i = 0; i < split.Length; i++)
[Code] ....
View 2 Replies
View Related
Apr 27, 2012
I have an ms access database with 2 tables in it which I named Customers and Products. I am using visual studio 2010, in my windows form I have 4 textboxes and 3 button in it, for my 1st textbox when I entered one of my ProductCode such as 10111, then press the Display button, the other remaining 3 textboxes should populate and display the following;
ProductID: CH001
ProductName: Chocolate Strawberry
ProductCode: 10111
Then the 2 remaining button named NEXT and PREVIOUS, should be able to display all my product name with 10111 product code.
View 7 Replies
View Related
Apr 26, 2014
I have my main.cpp like this:
#include <iostream>
#include "curve1.h"
#include "curve2.h"
using namespace std;
int main() {
Curve1 curve1Obj;
Curve2 curve2Obj;
[Code]...
Base class Score has two derived classes Curve1 and Curve2. There are two curve() functions, one is in Curve1 and other in Curve2 classes. getSize() returns the value of iSize.
My base class header score.h looks like this:
#ifndef SCORE_H
#define SCORE_H
class Score {
private:
int *ipScore;
float fAverage;
int iSize;
[Code]...
You can see that I have used curve1Obj to enter scores, calculate average and output. So if I call getSize() function with cuve1Obj, it gives the right size that I took from user in enterScores() function. Also the result is same if I call getSize() in score.cpp definition file in any of the functions (obviously).
.....
The problem is when I call curve() function of Curve2 class in main (line 23) with the object curve2Obj, it creates a new set of ipScore, fAverage and iSize (i think?) with garbage values. So when I call getSize() in curve() definition in curve2.cpp, it outputs the garbage. .....
How can I cause it to return the old values that are set in curve1.cpp?
Here is my curve2.cpp
#include <iostream>
#include "curve2.h"
using namespace std;
void Curve2::curve() {
cout << "getSize() returns: " << getSize() << endl; // out comes the garbage
}
Can I use a function to simply put values from old to new variables? If yes then how?
View 3 Replies
View Related
Apr 23, 2013
I cannot wrap my head as to how to access my enum class Azimuth.
Code: #ifndef BOUSOLE_H
#define BOUSOLE_H
#include <iostream>
#include <string>
#include "StringHandler.h"
class Bousole{
[code]...
And here is where I am trying to access my enum for testing/understanding purposes
Code: #include "Bousole.h"
using namespace std;
int main (int argc, char *argv[]){
cout <<"Start bousole" << endl;
Bousole b;
[Code] ....
View 6 Replies
View Related
Mar 22, 2013
Code:
#ifndef CANDIES_H
#define CANDIES_H
#include <iostream>
#include <fstream>
#include <Global.h>
class Candies
[Code]...
Code:
#include "Candies.h"
#include <Windows.h>
#include <iostream>
#include <fstream>
#include <sstream>
[Code]...
When I tested it, the file name in getName() outputted the right file name. However the file name in loadName() does not print out anything in the console window.
I want it to be so that the strings in [I]name_addTXT.c_str() in both functions are equal.
View 4 Replies
View Related
May 27, 2013
Running into a snag in my program. I can't seem to figure out how to have an object of a class be able to look at all the other objects of its own class.
Reasoning being, I'm working on a game with multiple ships flying around in the same space. Each ship is a class.
Each ship has an x and a y, and needs to compare the angle and distance of other ships' x and y coordinates to see if they're visible on the same screen.
How to tell an object to look at objects of its own class.
Here's some code:
common.h
#ifndef COMMON_H_INCLUDED
#define COMMON_H_INCLUDED
int dist(int x1, int y1, int x2, int y2);
int get_info(int which);
[Code] ....
Basically, I just don't know how to properly write a function, call, or how to get the info I need, to the Player::get_closest() function so that it can see the other play objects.
View 7 Replies
View Related
Jun 21, 2014
I have a class that uses std::vector. I push back class objects onto the vector but when I try to cout the data members (with get functions) I get garbage values.
Here is the class:
#ifndef JOBS_H
#define JOBS_H
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
using namespace std;
class Jobs{
[Code] ....
I know I am missing the implementation of several functions but I'm just testing my vector to see if it is working and it isn't. The getBlockValue() function should output 0 for each job. When I push back one object the output is 0. When I push back 2 objects the output is 0. However when I push back 3 objects I get random values. Why is this? I thought vectors were dynamic?
View 8 Replies
View Related
Mar 1, 2013
Here's a bit of code:
CvClimateInfo::CvClimateInfo() :
m_iDesertPercentChange(0),
m_iJungleLatitude(0),
m_iHillRange(0),
m_iPeakPercent(0),
[Code] ....
does this means that these variables are initialized with the values between parentheses?
View 2 Replies
View Related
Oct 9, 2014
In VC++ is there any inbuilt class for storying values inside an XML File, without using CLI?
View 14 Replies
View Related
Nov 22, 2014
This is a simple dictionary program, richtextbox is used for a results
but i wants to use textbox as a richtext box
(ex:money = dollar,penny,rupees)
as a list : dollarpennyrupees
/> /> /> />
Project 2 Dic.txt = Project 2 Dic.rar
Attached File(s) : Project 2 Dic.txt (61.32K)
View 1 Replies
View Related
Nov 3, 2014
WPF window I'm working on. I have a window that has a textbox to enter a name to search a database table for, and when the search button is clicked, the ID for that username will be returned to a separate textbox. The code I've written atm doesn't seem to be working, but it looks fine to me. Here's what I've got;
private void btn_SearchUsers_Click(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrWhiteSpace(txtb_SearchName.Text))
{
SqlConnection sqlCon = new SqlConnection(conStr);
[Code] .....
So, I have the value entered into the textbox to be searched for stored in a variable, I'm selecting the ID from the table when the name in the variable is found, storing the result in a DataTable, and then in my foreach loop, if I find the name (the name column being index 1 in the table), I set set the ID result textbox to equal the ID for that name (the ID column being index 0 in the table). I think the foreach part is what's throwing me off. Maybe the column stuff? My Users table is like;
ID Name
1 John
2 Roger
3 Mike
View 3 Replies
View Related
Jul 30, 2014
In my code below the first textbox.appendtext works but the second, textbox1.appendtext(i);, gives an error;
The name 'textbox1' does not exist in the current context (CS0103).
Is it possible to put text into the textbox from this routine?
namespace textboxtest {
public partial class MainForm : Form {
public MainForm() {
InitializeComponent();
[Code] ....
View 3 Replies
View Related
Mar 28, 2015
I was following a c# book to write a WPF with a textbox. When the textbox is selected(got focus) with keyboard or mouse, it will select all text in it. I followed the book and wrote this:
private void TextBox1_GotFocus(object sender, RoutedEventArgs e) {
TextBox1.SelectAll();
} private void TextBox1_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) {
var control = sender as TextBox;
[Code] ....
The book said having "e.Handled = true" is to stop the event in order to prevent the cursor being positioned on somewhere of the text instead of selecting all text. From my understanding, "e.Handled = true" is for stopping routed events. Is this means that something will run if "e.Handled = true" is not there? If yes, then what is it?
View 2 Replies
View Related
Dec 20, 2014
How to use Masked Text Box if I want to use a string for mask? There is a question in the program and I want to be able to type in only the correct answer. So if the correct answer is Blue, and I start typeing It only accepts for the first caracter is B, then l and so on...
View 11 Replies
View Related
Aug 5, 2014
I have a textbox with XAML
<TextBox Grid.Row="0" Grid.Column="1"
HorizontalAlignment="Stretch" VerticalAlignment="Center"
Text="{Binding Path = EventDate, Mode=TwoWay}" />
And the Property
[edit]Note that auto formatting has edited onpropertychanged to all lowercase[/edit]
/// <summary>
/// Date that the event took place
/// </summary>
public string EventDate {
[code]....
In the constructor I have
EventDate = "Enter Date";
I have added a button
<Button Grid.Column="3" Content="Add Record" VerticalAlignment="Center" Click="AddRecordButtonclick"/>
public void AddRecordButtonclick(object sender, RoutedEventArgs e) {
Debug.WriteLine("Date value: " + EventDate);
}
What I am finding when I run this code is that when the Add Record button is clicked, the output displays, "Date value: Enter Date" regardless of what text I have in the textbox bound to EventDate.
Is there something obvious which I am missing with binding of a string to a textbox?
I've added this to the xaml, but the property is still not updating in the debug line
<TextBox Grid.Row="0" Grid.Column="1"
HorizontalAlignment="Stretch" VerticalAlignment="Center"
Text="{Binding Path=EventDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
View 7 Replies
View Related
Oct 28, 2014
All I want is to let the user enter a value such as .55 or say, .34 and use that in a calculation.
I cannot get passed the errors.
double theRate;
double totalMileage;
double amountOwed;
private void btnCalculate_Click(object sender, EventArgs e)
[Code] ....
So how do you get numeric input from a user?
View 3 Replies
View Related
Apr 24, 2015
I have a silverlight app that uses TextBox XAML controls.
In the c++ code-behind, IXRTextBoxPtr types are associated with these textboxes using "FindName" like this:
FindName(L"ColNum3", &m_pColNum3);
(where ColNum3 corresponds with the XAML CODE like this: )
Then, the code assigns the pointer like this:
std::wstring wsTransfer; // gets the wstring from imput
const WCHAR * wpszInput;
wpszInput = wsTransfer.c_str();
m_pColNum3->SetText(wpszInput);
but the display does not show the text data.
What am I missing? What steps am I missing to have this text modification display on the screen?
View 6 Replies
View Related
Feb 13, 2013
how to add textbox in datatable in c#
View 3 Replies
View Related
Jan 26, 2015
I have a text format like this:
12-22-24-22-33-13
When user click a button then check for duplicated number in that text. How to handle this in C#.
View 1 Replies
View Related
Oct 31, 2013
I am writing a program in Visual C++ 10 with 2 forms.
In the first form I have a textbox and a button. The button opens the second form.
In the second form, I have a button that changes the text in the textbox in form1 to an item from a listbox in form2.
Here is my problem. When I do the code for the button in form2 to change the textbox in form1 I get the errors:
error C2065: 'textBox1' : undeclared identifier
error C2227: left of '->Text' must point to class/struct/union/generic type
I thought maybe I should just include the "Form1.h" file but I can't do that because I already included "Form2.h" in form1 in order to be able to open the second form. If I try to include form1 in form2, it says that the code to open form2 is an error now.
My question is, how can I access identifiers such as "textbox1" from other forms and other files when I already used the first form to open the second form? I also want to know how to do this for all identifiers between all files.
how to print the selecteditem from a listbox into a textbox because that doesn't work by just setting them equal either.
Here is my code:
#pragma once
#include "Form2.h"
namespace Test1 {
using namespace System;
[Code].....
View 11 Replies
View Related
Apr 13, 2014
How can i jump from textBox to next texBox when i press enterKey in c# , what i the event for that .....
View 2 Replies
View Related
Jul 12, 2014
This program with DLL that check number enter in textbox and use RGB for change color
example: if user enter 000 (000:black) changed color automatic textbox to black, and other 111 ....
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
[Code]....
View 4 Replies
View Related
Mar 16, 2014
I want to display a gridview when a textbox is focused. The gridview is hidden when the page is loaded and as soon as the focus is on the textbox the gridview should be visible.
Here is my code
<asp:TextBox CssClass="txt" ID="txtEducation1" AutoPostBack="true" runat="server" onfocus="MyFunction"></asp:TextBox>
protected void MyFunction(object sender, EventArgs e)
{
gridview1.Visible = true;
}
View 1 Replies
View Related
Sep 29, 2014
I'm having a little problem with System::String and terminating the text to end the line in the textbox, I tried adding
to the string in multiple ways (Insert, or just + " ")) but the text is still appended in one single line.
However converting a properly terminated char array to a string and appending it to the textbox works. So, let me explain my code a little more: I have a function which appends text to the textbox (I use it from a different thread thus I needed to use Invoke):
void mainTextboxAppendText(String^ text) {
if (this->mainTextbox->InvokeRequired) {
dMainTextboxAppendText^ d = gcnew dMainTextboxAppendText(this, &mainForm::mainTextboxAppendText);
this->Invoke(d, gcnew array < Object^ > {text});
} else {
this->mainTextbox->AppendText(txt + "
");
}
}
But when I try to call it multiple times with different strings then they do not appear in new lines but they're all in one single line, I've tried doing it like:
txt->Insert(txt->Length, "
");
this->mainTextbox->AppendText(tx);
I've also tried using Environment::NewLine, but it still didn't work, so what I finally came up with was converting the system string to an char array using Marshal and inserting an " " there and then converting it back to an system string, then it was ok .
View 3 Replies
View Related
Mar 2, 2014
So I have assigned this method to each TextBox. It works fine pressing the left arrow and right arrow, but for some reason will not work using the up and down arrows. I have tested the string, using MessageBox and it is correct...the loop even proves it finds a matching TextBox. It is correct as in it displays the TextBox name it should be selecting but doesn't. I have no clue! Now the first select method is the one I want to use, I used the loop to check to see if it was even finding a match. It does find it but doesn't select it. The naming convention for my text boxes is r1c1 where the first number indicates the row and the second number is the column. There are 9 rows and 9 columns. This SHOULD be working but for whatever reason it is not. I've even put a message box inside the if statement for the up and down keypress check and it pops up when i press up or down.
private void Navigate(object sender, KeyEventArgs e) {
TextBox input = (TextBox)sender;
string nextBox = input.Name.ToString();
if (e.KeyCode == Keys.Left) {
if (int.Parse(nextBox.Substring(1, 1)) > 1 && int.Parse(nextBox.Substring(3, 1)) == 1)
[Code] ....
View 7 Replies
View Related