|
Quite correct, Pete. I overlooked that...
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
|
|
|
|
|
Repost of my reply below for your attention:
itprs,
Adding to Dave K's comments (below) there's one book I've found to be a good introduction. Om Amazon:
Tcp/ip sockets in c# by makofske, donahoo, calvert
Isbn-13: 978-0-12-466051-9
Isbn-10: 0-12-466051-7
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
|
|
|
|
|
I want to Bind two Columns and populate a ComboBox with it in C#..My code is printing just one. the FirstName. Have tried concatenating the LastName with it but its not working. Can anyone show me how to go about it. Here is my code. Thanks
OleDbCommand cmd = new OleDbCommand("SELECT * FROM ADb", myCon);
OleDbDataAdapter d = new OleDbDataAdapter(cmd);
d.SelectCommand.CommandText = cmd.CommandText.ToString();
DataTable dt = new DataTable();
d.Fill(dt);
cmbNames.DataSource = dt;
cmbNames.DisplayMember = "FirstName";
|
|
|
|
|
You meant two rows? Whats the other value you want to bind or data in your table? If it the ID add it as Value Member
cmbNames.ValueMember = "id";
Bombo box will bind row by row from your table.
I remain joe!
|
|
|
|
|
You have just provided the code and query for the Firstname, please provide the same code for Lastname too.
|
|
|
|
|
One approach is to retrieve the data in the format you want:
OleDbCommand cmd = new OleDbCommand("SELECT id, FirstName + ' ' + LastName as Name FROM ADb", myCon);
OleDbDataAdapter d = new OleDbDataAdapter(cmd);
d.SelectCommand.CommandText = cmd.CommandText.ToString();
DataTable dt = new DataTable();
d.Fill(dt);
cmbNames.DataSource = dt;
cmbNames.DisplayMember = "Name";
I took a guess at the name of your ID column. You still need to select that if you use the combo for selecting things elsewhere.
|
|
|
|
|
Thanks BobJanova. Thanks Everyone...
|
|
|
|
|
You can append two columns in SQL query and use that column as display Member
SELECT Firstname + ' ' + Lastname,* FROM ADb
|
|
|
|
|
Hi all,
Just got a view and a viewmodel to wire-up. The view needs to be bound to some properties that will be resolved asyncly after the execution of a certain command.
Ok, I wrote all the stuff but now i'm confused with how to declare the binding???
Any ideas????
Here's just a skeleton
View -
initially just a textbox and a ok button. On clicking the ok button, the results are displayed and the command to resolve values are sent to the viewmodel.
In viewmodel,
public class MainViewModel : ViewModelBase<MainViewModel>
{
private string _data;
private int _time;
public string Data
{
get
{
return _data;
}
set
{
_data = value;
NotifyPropertyChange("Data");
}
}
}
I need the value of a Textblock to be bound with "Data". But that will be resolved after a while...
Out of ideas! Please help.
modified 4-Jun-13 12:51pm.
|
|
|
|
|
Try <textblock text="{Binding" data}=""> from within the view.
|
|
|
|
|
<Textblock Text="{Binding Data}" />
This will be enough? so simple!
Ofcourse, the confusion was that it was to be resolved asyncly.
|
|
|
|
|
I am still not getting it, how exactly do you want to bind your data with the ViewModel.
|
|
|
|
|
Binding to that property in the normal way should work fine. Data binding is essentially asynchronous all the time, in that the view's updated by notification events and not directly by code, so it should work just the same.
Make sure that the VM sends a value that the view can deal with before the asynchronous call returns, though (this might mean making the view accept null).
|
|
|
|
|
Thank you,
Here's my solution,
<Textblock x:Name="result" Text="{Binding Data, TargetNullValue=Loading..." />
|
|
|
|
|
My final year project is to find the distance and height of image from camera(webcam). Is there some way in C# to find the angle of pointing image from the camera ? Please help me I have few time only
bishwazeet
|
|
|
|
|
Bishwajit Nepali wrote: Please help me I have few time only One can't build a castle in a day. You're lucky though; we have an article[^] on images and distances.
For an angle, one would need a reference-point.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thnx but I did using the reference point .Thanks for ur suppoort
|
|
|
|
|
The concept that you are talking about is like a program that can't be developed within a day.
|
|
|
|
|
The way to solve this is to use some maths, and it requires you knowing how high off the ground the web camera is. Once you know this, you need to measure the angle to the base of the object to work out the distance. From this, it's a fairly simple set of calculations to work out the height (as long as you know the angle to the top of the object).
|
|
|
|
|
thank you every body for your suggestions. I am very greatful to you all
|
|
|
|
|
Drill 4-4
Rewrite the program created for Drill 4-2 to read the number and the
power as program arguments.
This first set of code is what I wrote for Drill 4-2.
The second set of code is what I'm attempting to write.
I've read all the articles at MSDN and even watched a few YouTube videos to try to find out where I'm going wrong.
I know it's probably something very elementary, but… My blue-collar butt is having a little hard time trying to figure out this white color stuff.
Instead of actually writing and giving me the code, give me written instructions… So I could practice with written instructions as well.
Don't give me a link to another article, I've read as many as I could in the past few days trying to figure it out.
I'm just not quite thinking like a programmer yet. I need some practice in taking the written instructions.
I imagine the book I'm reading will eventually talk about the "public, void, private, partial, static" keyword sooner or later.
I'm not taking any formal classes, I'm trying to learn this on my own time. That's why I'm asking for written instructions so I can get a better grasp on how to use this language in the right context.
I have two blue squiggly lines in my main method for the integer variables.
Error message:
use of unassigned local variable 'num' and 'num1'
using System;
namespace CalculatetothePowerof
{
class Program
{
static void Main2()
{
int valOne = AcceptValue("Enter your first number:");
int valTwo = AcceptValue("\nEnter your second number:");
Console.WriteLine(Math.Pow(valOne, valTwo));
Console.Read();
}
static int AcceptValue(string message)
{
string valueOne;
int IntOne;
string YesNo;
do
{
Console.WriteLine(message);
valueOne = Console.ReadLine();
IntOne = Convert.ToInt32(valueOne);
Console.WriteLine("Are you sure you want to use that number?\nPress lowercase y or n, to continue.");
YesNo = Console.ReadLine();
if (YesNo == "y")
{
break;
}
Console.Clear();
} while (YesNo != "y");
return IntOne;
}
}
}
using System;
using System.Text;
namespace MainMethodAcceptTwoArgValues
{
class Program
{
static void Main()
{
int num;
int num1;
UserInput(num);
UserInput(num1);
Console.WriteLine(Math.Pow(num, num1));
}
static void UserInput(int input)
{
string userinput;
string yes_no;
do
{
Console.WriteLine("Enter your number: ");
userinput = Console.ReadLine();
Console.WriteLine("Correct numbers?\nPress y/n");
yes_no = Console.ReadLine();
if (yes_no == "y")
{
input = Convert.ToInt32(userinput);
break;
}
Console.Clear();
} while (yes_no != "y");
}
}
}
|
|
|
|
|
WidmarkRob wrote: I'm not taking any formal classes, I'm trying to learn this on my own time.
Stop doing that - it's a pretty poor way to do things. If you are following a book, or other training course, then fine, but if you are just trying to pick it up "randomly" as you go, then stop right now! Your will miss too much stuff, which can save you a lot of time and heartache later!
Having said that, your error is pretty simple, and the error message is pretty explicit:
use of unassigned local variable 'num' and 'num1'
What that means is that when you pass the value of the two variables to your UserInput method, you have not assigned them any value, so there is no value to send. Since at compile time it doesn't know anything about the UserInput method it complains, because the way you have defined things it has to assume that UserInput is expecting to use the value, not set it.
There are two ways to solve the problem: change the UserInput parameter to an out paramater - in which case no value is carried in, only out of the method:
static void Main()
{
int num;
int num1;
UserInput(out num);
UserInput(out num1);
Console.WriteLine(Math.Pow(num, num1));
}
static void UserInput(out int input)
{
... Because an out parameter does not copy any data from the calling method, but modifies the variable when it returns. But then the compiler will very probably complain that input is not given a value in all code paths.
The better solution is to not pass anything in - return a value instead:
static int UserInput()
{ But I don't think what you are doing is what the exercise calls for. I'm not quite sure what your instructions mean, but I suspect that what they should be doing is not reading values from the user at all - "program arguements" means something very different and specific here.
Where did you get the exercise? What was it related to?
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
OriginalGriff wrote: Stop doing that - it's a pretty poor way to do things. If you are following a book, or other training course, then fine, but if you are just trying to pick it up "randomly" as you go, then stop right now! Your will miss too much stuff, which can save you a lot of time and heartache later!
maybe I should have said semi-informal/self-paced study…http://www.brainmeasures.com/courses/online/626/c-sharp-certification.aspx
it was a little confusing at first, but… With the help of Richard, I was able to figure it out and understand what the book was asking of me to do…
thanks for your help as well, it helped clarify what I could possibly do in the future using different keywords.
Thank you
|
|
|
|
|
You're more than welcome for any help I gave!
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
You need to use the argument array that is provided by the system, as shown below:
static void Main(string[] args)
{
int number = Convert.ToInt32(args[0]);
int power = Convert.ToInt32(args[1]);
Console.WriteLine(Math.Pow(number, power));
}
You would then call the program in a command window by something like:
programname 23 3
Use the best guess
|
|
|
|