|
string[,] PageArray = { { "TextBox2", "Wilson" },
{ "TextBox3", "Bob" } };
|
|
|
|
|
Once the array exists, you can't add to it. You need to use a List or something, instead. You can make a list of lists, to get a 2D effect. Or, you can create a struct to contain the two values you want in each element.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: Once the array exists, you can't add to it. You need to use a List or something, instead. You can make a list of lists, to get a 2D effect. Or, you can create a struct to contain the two values you want in each element.
This is a good point. I wasn't sure if he meant add in the sense of adding to an array after it has been created or add in the sense that he wasn't sure how to initialize it with the additional values.
Another possibility other than the ones you suggest is to use a Dictionary if his collection can be characterized as key/value pairs.
|
|
|
|
|
Good point, the Dictionary is a container that's hard to beat
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Are you sure he was not asking how to initialize the size of the array and then fill it in with information? Because that would just require setting the size for each dimention [5,5] for a 5x5. Then to add to the filled out dimensions you would just use array[0,0]= or array[0,1]=. If you use a multidimensional array I have found it really helps to map it out on paper first. Of course you could always just use a dictionary.
_____________________________________________________________________
Our developers never release
code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
Visit Me at GISDevCafe
|
|
|
|
|
Hello!
I work in am TFS in my job ... and I receive a computer from another coworker and I need to login to TFS with my account...but VC# are login with his account.
Have anyone a suggestion about how can I change this.
thnx
|
|
|
|
|
My experience is, that TFS tries to log in using the username and password the computer was logged in with, if this fails, it pops up a login screen.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I am new to the whole c# world but I noticed something kind of strange to me. If I have an interface that has a property and I use both get and set in my implementing class, it doesn't break as long as I declare either get or set or both. If I use both, shouldn't the interface require me to declare both?
interface IReadThings
{
int Status { get; set;}
}
public class TheDoc : IReadThings
{
public int Status
{
get { return theStatus; }
set { theStatus = value; }
}
}
|
|
|
|
|
santhony7 wrote: If I use both, shouldn't the interface require me to declare both?
Nope. Say you have a readonly (get) property declared in an interface. In your implementing class, you have to implement the property with a getter. However, the setter is optional. If you implement a setter as well, it's not covered by the interface but is rather specific to the implementing class. For example:
using System;
using System.Collections.Generic;
using System.Text;
namespace InterfaceTest
{
class Program
{
static void Main(string[] args)
{
IReadThings things = new TheDoc();
int s = things.Status;
things.Status = 42;
}
}
interface IReadThings
{
int Status
{
get;
}
}
public class TheDoc : IReadThings
{
int theStatus = 0;
public int Status
{
get { return theStatus; }
set { theStatus = value; }
}
}
}
The above doesn't compile because "things" is a reference to the IReadThings interface. Thus it represents only the functionality declared by the IReadThings interface. Since IReadThings doesn't have a setter for the Status property, we get a compile error. Had we made "things" of type TheDoc , it would compile just fine.
The interface represents a blueprint that an implementing class must implement. However, the implementing class is free to provide additional functionality that goes beyond the interface's contract. This includes properties providing a getter or setter if one isn't specified by the interface.
|
|
|
|
|
Thanks man, that really helps. I understood about 69% of what you said but I am learning quick...
|
|
|
|
|
The only thing I might add to make this answer a bit more plain to understand is that Interfaces are often referred to as "contracts." That is, they represent an obligation of the implementing class to support whatever is declared in the interface. However, by no means are interfaces to restrict the implementing class to only what is promised in the interface.
|
|
|
|
|
How can I control the order that my properties appear in the DataBindings BindingSource selection dialog? Sorted alphabetic would be nice.
I have a business object that inherits from a bindingsource. Its properties appear to be in an apparent random order in the binding source selection dialog. For example when I'm selecting a property to bind to a text box text property.
|
|
|
|
|
I'm thinking you might be able to do something like that by inheriting from ExpandableObjectConverter. I'm not sure, but it'll give you something to try out.
public class MyClass : ExpandableObjectConverter
{
public override bool GetPropertiesSupported(ITypeDescriptorContext context)
{
return true;
}
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
{
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(value, attributes);
return properties.Sort(new string[] {"Name", "Value"});
}
}
|
|
|
|
|
That was just the lead that I needed. I'm inheriting from a bindingsource and it implements ITypedList which has the GetItemProperties function. I overrode that function and simply added .Sort to base.GetItemProperties(listAccessors)
Thanks
|
|
|
|
|
Excellent. That's much more elegant. I believe my suggestion was a carry-over from 1.0 days. I know I did something like that (probably for a property grid) a long time ago.
|
|
|
|
|
I want to write codes of an adjusted affine transformation which works interactly. And my question is,
The user, browses and opens a picture file. I would like to get the pixel coordinates (x,y) of a point which is clicked by mouse. So, an event should be done. i am planning to write this in C# but if u have any ideas in other programming languages, please, don't hesitate to write. : )
Thank you.
|
|
|
|
|
I'm guessing you're putting the picture in the picture box, so you can add a PictureBox1.MouseClick event and in the event you can get the coordinated like this: e.X (for the X coordinate) and e.Y , or alternately: e.Location.X ,e.Location.Y
|
|
|
|
|
You can use javascript.
on_click event, use following code
tempX = event.clientX + document.body.scrollLeft;
tempY = event.clientY + document.body.scrollTop;
Nana
|
|
|
|
|
Thank you for your responds. pictureBox tool has an event like this but i couldn't see.
|
|
|
|
|
I have a textbox and two radio buttons. If the value in the textbox is negative, radiobtn2 should be selected otherwise if it is positive radiobtn1 should be selected.
First, the code:
this.textbox1.Leave += new System.EventHandler(this.textbox1_Leave);
private void textbox1_Leave(object sender, System.EventArgs e)
{
string firstchar = textbox1.Text.Trim().Substring(0, 1);
//MessageBox.Show("function called");
if(firstchar == "-")
radiobtn2.Select();
else
radiobtn1.Select();
}
The strange behavior is:
1) that his works if I Tab out of the textbox but not if I click out of the textbox.
2) I put a simple messagebox.show in the textbox1_Leave function to see if it was being called, and the messagebox appears when I click out of the textbox and the code then works with a radiobtn being selected! This tells me the function is being called, but when I remove messagebox.show the function again no longer works!
I also tried changing the EventHandler from Leave to LostFocus and the same behavior exists.
Any ideas why this is or what I can do to work around it without having the user's progress be interrupted?
Thanks,
RABB17
"Nothing fancy needed, please just solve all our problems as quickly as possible."
|
|
|
|
|
use radiobtn1.Checked = true; instead of Select
|
|
|
|
|
Thanks Sharpie that worked perfectly! Another example of being too close to the problem
Thanks again,
RABB17
"Nothing fancy needed, please just solve all our problems as quickly as possible."
|
|
|
|
|
hi,
does anyone know how i can copy a complete dir, including subdirs and files to another drive, using c# ?
or do i have to copy each dir separate ?
thx
Kurt
|
|
|
|
|
Try this link. http://www.aspemporium.com/howto.aspx?hid=20[^]
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|