Try typing the IntegratedSecurity line after you have specified the ReportSource.
jatin24 21 Junior Poster in Training
jatin24 21 Junior Poster in Training
terdie commented: thanks man! +1
Try typing the IntegratedSecurity line after you have specified the ReportSource.
Try this:
crystalReportViewer1.LogOnInfo[0].ConnectionInfo.IntegratedSecurity = true;
Insert this line after you've set the ReportSource property.
Just use the following in your combo box selected index changed event handler
string font = comboBox1.SelectedItem.ToString();
label3.Font = new System.Drawing.Font(font, 14);
I just tried that and it works.
Instead of comboBox1.SelectedIndex, try using comboBox1.SelectedItem
Try this:
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.Connection = cn; // This is your connection string
cmd.CommandText = "SELECT * from zip_table where zip = " + textZip.Text;
cn.Open();
SqlDataReader dr = cmd.ExecuteReader();
dr.Read()
textCity.Text = dr["City"].ToString();
textState.Text = dr["State"].ToString();
cn.Close();
Im assuming you have your connection string sorted out (cn).
I would personally use stored procedures instead of a direct query, but this one will work just as well.
I've done something like that in an application i built sometime ago.
firstly, you dont need two seperate tables. Just have one table with the zip code, city, state etc and everything you need.
You can create a button next to the text box and on the click event, just write the code for connecting to the database and running a simple query like
SELECT * from zip_table where zip = <<zip code from textbox>>
Get the result and display in the relevant text boxes..
You can probably use something like an ArrayList and keep storing each and every path traversed there. So if you wanna go back, the last path stored will be the last visited and so on.
To check if you are at the root, you can check the number of "\" in the path string....
Use:
description = description.Substring(0, 14);
or..
under the console.WriteLine(), display description.SubString(0,14) instead of just description. :)
I'll post my code after my questions.
1. Near the very end, I have DisplayIntroMessage() called for the event that the user desires another order. Is this all that I need to do to restart the process?
Yes that should restart the process.
2. If that is all that is needed, what is the easiest way to save the total from each prior order(s) to add to newer ones.
Are you trying to save individual orders? in that case you can make a global ArrayList and store whatever you want in there.
If you wish to permanently store the totals, you might have to use file IO.
3. In the DoTheMath() method, I am asking the user whether or not they desire another order? I'm not getting this to work out just right. I don't know what to do with it. I've tried several things only to end up unsuccessful in all of them.
your if statement is wrong.
if (anotherOrder != "yes" || anotherOrder != "no")
This will always return true no matter what you enter.
Also, you are using Convert.ToChar(), and comparing a string.
simply use the ReadLine() function to read the input. This will be in string.
change it something like this:
int flag = 0;
do
anotherOrder = Console.ReadLine();
if (anotherOrder == "yes" || anotherOrder == "Yes" || anotherOrder == "YES")
{
DisplayIntroMessage();
flag = 1;
}
else if (anotherOrder == "no" || anotherOrder == …
Put the code for Converting to datetime and validating in the 'Leave' event handler for the textbox.
In that case you will have to parse the input using the following:
DateTime input = DateTime.Parse(textBox.text);
// you can now use the variable input to check..
You will have to make sure that the input is in correct format. Put this in a try catch to avoid application to crash.
Well..yeah.. wasent sure if he ment 5 years ahead of today or 5 years before today! I assumed its checking the date to be withing 5 years ahead of today.
simply use the 'Value Changed' event of the DateTimePicker control.
if (dateTimePicker1.Value > DateTime.Now.AddYears(5))
MessageBox.Show("Date should be within the next 5 years");
Well if you are opening form2 from form1, then it can be done quite easily.
Simply create a public class level variable in form2:
public string myStr;
In form1, use this to open up form2:
form1 f = new form1();
f.myStr = textbox1.text;
f.show();
could'nt really understand the 2nd half of your message. x and y are classes or functions? what exactly are you trying to do there?
Well in any database driven application, i think any changes to the database will cause a lot of trouble in the working of the application. Esp if you are playing around with columns of tables.
While adding/removing columns, you will have to make appropriate changes in the queries/stored procedures as well, else you will get lots of errors.
If you want to remove a column, i dont think theres anyway to do that without loosing the data. Unless you retrieve all the values of that column in your application somewhere, and then store it elsewhere (a file or maybe in the database itself).
Well you can put the code i gave you in a function, and call that function in each textBox TextChanged Event.
You can use textBox Leave Event as well if you like, if you dont want the function to be called after each key stroke.
Did'nt quite understand your question...
Just use the following statement:
BTNAPPLY.Enabled = true;
inside the TextChange Event handler of the text box and the SelectedIndexChanged event of the combo box.
for the TextChange Event handler:
if (textBox.Text == "your required text")
BTNAPPLY.Enabled = true;
for the SelectedIndexChanged Event Handler
if (cmbBox.SelectedItem == "your required seleciton")
BTNAPPLY.Enabled = true;
Assuming that the button is disabled when the application starts.
try this:
int n = listBox1.SelectedItems.Count;
string[] array = new string[n];
for (int i = 0; i < n; i++)
{
array[i] = listBox1.SelectedValue.ToString();
}
You need to look at 'Setup and Deployment'
You will need to create a new project. Under 'Other Project Types' you will need to select 'Setup and Deployment'.
Depending upon your requirements you can choose the type of 'Setup and deployment' you would like to use. I guess 'Setup Project' would be the best.
You need to add this solution to your project that you want to create setup for.
You can read more about it here..
It looks like a web service, its asking for an API Key when trying to access that link. Not sure though.
Use try...catch, you might be able to find out which exact character is invalid which may lead to a clue.
To fetch all the occurrences, you can use a loop as well. Something like this:
ArrayList indx = new ArrayList();
for (int i=0;i<nums.Length;i++)
{
if (nums[i] == 14)
indx.Add(i);
}
At the end of the loop, the ArrayList indx will hold all the indexes that hold the number 14. You can read more about ArrayList. you can do a lot more with it as compared to Array.
Check the code of HelpBox.cs. Im assuming that the name of the partial class inside that file may not be matching with the filename - HelpBox.cs.
Maybe the name of the form was changed after it was initially created but the class name was not changed.
Try this:
string formText = this.Text;
string input = textBox1.Text;
int flag = 0;
if (input.Length < formText.Length)
{
for (int i = 0; i < input.Length; i++)
{
if (input[i] == formText[i])
flag = 1;
else
flag = 0;
}
if (flag == 1)
{
// The string is equal to the form heading or the start of the form heading.
// do something.
}
}
Try clearing the DataTable as well before populating it.
No Worries!
Please mark the thread as solved if you think you've solved the problems you were facing!
You can use static variables.
In your MyInputForm class, declare a variable as follows:
public static String name;
This variable can now be accessed from anywhere/any class within the application using the following:
The current value of the variable 'name' can be accessed using this.
Hope this helps!
1) Use the control 'ContextMenuStrip'. You can Easily add items to this controls. Once done, use the Right click event of the dataGridView control you have in your application, and display this contextMenuStrip at the current location of the mouse.
2)Use the KeyPress event handler for the textbox and type in the following:
if (e.KeyChar == '\r')
btnSubmit.PerformClick();
where btnSubmit can be replaced by the name of your button.
3)When changing colors, if you want the colors to be exactly the same if you change the theme of windows or version, use Web or Custom Colors and not the System Colors.
Hope this helps.
Hello,
In order to introduce myself to C# and, in particular, Visual C# I decided to make a small program with 'windows forms'. At the moment I have some questions:
1) Im using a grid (dataGridView). I'd like a menuStrip (I dont know if is exacly that component) to appear when the mouse's right button is clicked. For each row of grid, when I click on the mouse's right button, a menu with options appears. How can I do that?
2) Something is typed in a textBox. I would like to, after that, ENTER key is 'activated' so I don't have to click on a button, I just press on ENTER key. How can I do that?
3) Last question. Im coding in win Vista where I changed the appearance of dataGridView (row's selection color, etc). However when I tried …
well first of all, you can return only one variable from any function. So 'return name, ref_no;' is wrong.
I dont think you can change the return type of an event handler. An alternative can be to create global variables, and setting the values of those variables when the button is clicked. And then accessing those variables from wherever you want after the click.
regards