|
Have a play with the MultiSelect property on the grid
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Assign an array of objects to PropertyGrid's SelectedObjects[^] property. Note the plural-s.
PropertyGrid will then sort out what properties to display and what values to display for shown properties in the usual way.
Ciao,
luker
|
|
|
|
|
Hi,
I am trying to use Modern UI Charts for my Windows Store app but I am not able to get it working.
A similar issue was logged by another person here along with the code
Can anyone please help??
|
|
|
|
|
Does this third party support WIndows 8? Check if they have documentation that tells you what versions they support.
|
|
|
|
|
Yes it does.. Clearly stated in the documentation
|
|
|
|
|
Raghavendra Reddy C wrote: Can anyone please help??
Given how little information you've given us, no. There's no source for us to view, and there's precious little detail about not being able to get it working in there.
|
|
|
|
|
|
|
|
Raghavendra Reddy C wrote: A similar issue was logged by another person here along with the code And also a link to the solution.
Use the best guess
|
|
|
|
|
hi,
I am trying to write some data to local port to open the cash drawer....
with this simple code
private void button1_Click(object sender, EventArgs e)
{
serialPort1.Open();
serialPort1.PortName = textBox1.Text;
serialPort1.Write("16 20 1 0 1");
serialPort1.Close();
}
However the Port is not recoginized in C# unless it's a COM port...
My printer somehow say it should be a local port with the name USB_BTP-R880NP_1 (as the name of the printer) .. How can i communicate with it without using a COM command from C#...
Second question is
in the reference, it said to send data to the port to open cash drawer by following this format :
ASCII DLE DC4 n m t
HEx 10 14 n m t
Decimal 16 20 n m t
Range n = 1
m =0,1
1<=t <= 6
Is my command above correct?
Thanks
|
|
|
|
|
Surprisingly, the SerialPort class in C# is designed specifically to talk to serial ports... You cannot talk to a USB device through the SerialPort class, no matter what name you give it. It will only work with COM ports.
Most cash drawers are serial though, are you sure that the cash drawer is connected via usb? If thats the case, you will need to get some sort of driver API to communicate with the usb device through a windows driver and hooks, not a very easy task. Sending raw data to a USB port through the WinAPI involves knowing device descriptors and endpoints that are difficult to know unless you have an intimate knowledge of the driver structure.
As far as your second question, thats something only the manufacturer can tell you. Without having more knowledge on our part, like a manual or interface document, we can't tell you if what you typed is right or wrong.
|
|
|
|
|
Hello All
I am trying to implement MVVM and use IDataErrorInfo interface to validate data in the model classes
I base model class implementing IDataErrorInfo interface
public class BaseClass: IDataErrorInfo
{
<Properties and Members of BaseClass>
#region IDataErrorInfo
public string Error
{
get { return String.Empty; }
}
public string this[string PropertyName]
{
get { return this.GetValidationError(PropertyName); }
}
#endregion
}
Now I want drive a class from Base class
public class DrivedClass: BaseClass
{
}
How do I use IDataErrorInfo members in the derived class to carryout validation of the properties in the derived class??
|
|
|
|
|
You can mark them as virtual and override them in the derived class.
|
|
|
|
|
Okay, declaring arrays is fairly simple… Just like declaring any other variable with the exception of the square brackets.
Initializing one-dimensional arrays also seems fairly simple enough… Initializing two-dimensional arrays is a bit more complicated but still semi-sort of simple if you pay attention to what you're doing.
Jagged arrays, like two-dimensional arrays… Can be a little tricky if you're not paying attention.
I get and understand the declaration and initialization of the jagged arrays, and that you can change the value of any element by re-declaring your array variable…
I'll use the example from the book I'm reading:
(never mind some of the missing closing curly brackets, before I add any more code I want to understand and learn this part first)
using System;
class JaggedClass
{
static void Main ()
{
int[][] myJaggedArray = { new int[] {2, 3, 4}, new int[] {5, 6, 7, 8, 9} };
myJaggedArray[0][0] = 11;
myJaggedArray[1][2] = 22;
Okay, you old pros… Here is the drill/exercise I was supposed to work on:
Drill 4-3
Display the contents of the two-dimensional array called “grades”
that was discussed in this section. Make sure you get the following
result:
Grade=Pass Score=55%
Grade=Good Score=65%
Grade=VeryGood Score=75%
Grade=Distinct Score=85%
The book was showing us three different ways to declare and initialize a two-dimensional arrays.
This is the first way it showed us:
string[,] grades = new string[2, 4] { {"Pass"," Good", "VeryGood", "Distinct"}, {"55%", "65%", "75%", "85%"} };
this is the second way:
string[,] grades = new string[,] { {"Pass", "Good", "VeryGood", "Distinct"}, {"55%", "65%", "75%", "85%"} };
third and final way:
string [,] grades = { {"Pass", "Good", "VeryGood", "Distinct"}, {"55%", "65%", "75%", "85%"} };
I know I probably could have achieved the same result with a "for loop, or a for each loop, maybe even the while loop", but… I couldn't quite figure it out, I beat my head against the wall for almost half an hour trying to figure the loop out… So, I went a different route… The long and hard way…
It took me about 15 min., maybe even 20 min. to even figure that out… My ah-ha moment came when I accidentally printed to the screen the word "Good"… Don't laugh… I said don't laugh at!
I wrote it and I achieved the way it looks in the book, you'll have to compile it in debug it yourself to see what it looks like… I haven't figured out how to format things here in the forum yet.
using System;
using System.Text;
namespace Two_Dimensional_Array
{
class Program
{
static void Main(string[] args)
{
string[,] grades = { { "Pass", "Good", "VeryGood", "Distinct" }, { "55%", "65%", "75%", "85%" } };
string[] gradeScore = {"Grade=", "Score="};
Console.WriteLine(gradeScore[0] + grades[0, 0] + " " + gradeScore[1] + grades[1, 0]);
Console.WriteLine(gradeScore[0] + grades[0, 1] + " " + gradeScore[1] + grades[1, 1]);
Console.WriteLine(gradeScore[0] + grades[0, 2] + " " + gradeScore[1] + grades[1, 2]);
Console.WriteLine(gradeScore[0] + grades[0, 3] + " " + gradeScore[1] + grades[1, 3]);
Console.Read();
}
}
}
modified 22-May-13 21:06pm.
|
|
|
|
|
WidmarkRob wrote: myJaggedArray[0][0] = 11; myJaggedArray[1][2] = 22;
Not quite. A jagged array is essentially an array of arrays. In your sample code, the myJaggedArray variable is an array containing two elements: an array of three integers, and an array of five integers.
myJaggedArray[0] returns the first element, so myJaggedArray[0][0] = 11 is updating the first element of the array stored in the first element of myJaggedArray , and myJaggedArray[1][2] = 22 is updating the third element of the array stored in the second element of myJaggedArray .
http://msdn.microsoft.com/en-us/library/2s05feca.aspx[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
WidmarkRob wrote: the first set of brackets closest to the variable is telling me to access the first element in the jagged array? Then the set of brackets furthest away from the variable is telling me to access the first element, inside of the first element of the jagged array?
Yes, that's correct.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
In addition to Richard Deeming's comments, a 2 dimensional array is just like a square (or oblong) containing N rows, and M columns. So element[0][0] is row 0, column 0, and element[1][2] is row 1 column 2. Try the following for a better illustration:
int[][] myJaggedArray = { new int[] { 2, 3, 4 }, new int[] { 5, 6, 7, 8, 9 } };
for (int N = 0; N < myJaggedArray.GetLength(0); ++N)
{
for (int M = 0; M < myJaggedArray[N].GetLength(0); ++M)
{
Console.WriteLine("element[{0}, {1}] = {2}", N, M, myJaggedArray[N][M]);
}
}
Use the best guess
|
|
|
|
|
one thing I'm going to have to remember about two-dimensional arrays is that the first set of brackets closest to the variable are rows and the second set of brackets are the columns?
Then having to remember if it's a jagged array, the two sets of brackets are accessing the elements differently.
Newbie question… You can declare and initialize brand-new data types and variables in the conditional expression/statement?
|
|
|
|
|
WidmarkRob wrote: and the second set of brackets are the columns? Exactly, it gets a bit more complicated when you go to 3 or more dimensions.
WidmarkRob wrote: You can declare and initialize brand-new data types and variables in the conditional expression/statement? Sorry, but I don't understand what you mean by that.
Use the best guess
|
|
|
|
|
This I can see is the start of the for loop with the conditional expression/statement in the parentheses.
You don't have to declare and initialize a variable before starting the for loop?
It looks like you're declaring and initializing a variable as part of the conditional expression/statement and then using the variable right after that…
is my verbiage all wrong?
for (int N = 0; N < myJaggedArray.GetLength(0); ++N)
|
|
|
|
|
Yes, you can declare and initialize the loop control variable in the for statement itself.
http://msdn.microsoft.com/en-us/library/ch45axte.aspx[^]
Note that the scope of that variable is only the loop.
Specifically, you cannot examine that variable after the exiting the loop.
|
|
|
|
|
WidmarkRob wrote: is my verbiage all wrong? Not really, perhaps, my understanding was. Your question (I think) is about where to declare the loop variable. It is largely a question of where the variable is to be used. Consider the following code:
int index;
for (index = 0; index < someValue; ++index)
{
}
if (index == someOtherValue)
for (int index = 0; index < someValue; ++index)
{
}
if (index == someOtherValue)
Use the best guess
|
|
|
|
|
Richard MacCutchan wrote: myJaggedArray.GetLength(0);
either my book doesn't cover this method you're using or it did and I forgot and I have to go back and read it, I know your buddies book probably covers that, I will read it later…
One other thing, you start talking about two-dimensional arrays and then you post in your code a jagged array.
Jagged Array
int [][]
Two-dimensional Array
int [,]
Right?
|
|
|
|
|