I don't think you can unless the height to width ratio of the picture box exactly matches that of the image. Your resulting image will either be distorted or too wide/narrow for the picture box. This article[^] explains the issue and offers a solution which may help you; the code is C++ but should be easy to understand.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
Thanks. The solution shown in the C++ article shows how to size the image and then it's just a matter of setting the PictureBox ClientSize to the image size. This seems to size the image correctly and maintains the ratio.
I have an array of UserRights (class that holds the rights for an individual table) called arrTables and an array of controls called arrControls (10 of each type of control needed). The arrControls are displayed/listed on a Windows form (TableName, ViewRights, EditRights...) so that the data for 10 tables can be viewed at one time. I've bound the data to the form controls using the following code:
When I try and display the form to the user data from the 10th table stored in the arrTables array is displayed in all 10 sets of controls. I learnt that the CurrencyManager holds the value of the Current possition and that is the reason for these results.
Is there a way around or an alternative way to implement this without hacing to use a datGridView or other list control?
It sounds as though you should be using a view of the data instead of binding to 10 different datasource all at once.
But since you appear to want 10 seperate data navigations going on at the same time you'd use 10 BindingSource objects, each having its DataSource property set to the table you want it to navigate over, then set each controls DataSource property to the BindingSource it should be using.
Thank you for your reply. I've attempted to follow the steps above only the array of controls doesn't have a DataSource method, so I'm unable to set the DataSource of the controls in the array to a BindingSource. Here is what I have:
BindingSource bs1 = new BindingSource();
bs1.DataSource = arrTables;
Could you tell me how I would go about assigning each controls DataSource property, in the array to a given BindingSource?
Thank you both for your feedback. I'm going to try the BindingSource objects recomendation now.
Bob- the method you sujected, does this take into account that there are more than 10 objects that need to be binded to the controls? There will be 10 objects bound at any one time, but then I have next and previous buttons to display the next and previous 10 objects.
The question is of pure interest: how do you prefer naming a variable/parameter of type Object?
Most of the time it depends upon the logic of its usage, but not always. Sometimes you just want to express a generic entity:
public byte Encrypt(Object x)
public byte Serialize(Object o)
Its tempting to name x as obj or objToEncrypt, but it sounds more like a Hungarian notation.
So how would you consider naming it?
Thanks for suggestion,
I was always tempted to append "to". In that case it would be toEncrypt. But it scratches my ear badly. I really like encrypt but its a verb, and it breaks the convention a little.
As for your CommandDoSomething.DoSomething example. I might have misunderstood you, but I prefer not appending action name to class name or viceversa:
User client = User.Create();
User client = User.CreateUser();
Anyway, I believe its a matter of preference
The only time I even append a type to an object name is when I'm naming controls. For example, Building_TextBox or Building_ComboBox. It comes in handy if you have a couple of controls related to the same thing.