|
Dunno - but this is making my brain hurt! (I had forgotten about the System.Type class; I try to avoid using reflection if I can.)
What is he doing that makes the size of a Type important, I wonder?
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
OriginalGriff wrote: What is he doing
Waiting for Friday?
|
|
|
|
|
Hi,
There is a Type class, with a constructor. And object.GetType() returns a Type instance. So there are type objects, and they all must have the same size; not sure how to get its value, I expect it to be small. Furthermore an experiment shows the type objects are unique, i.e. there is at most one for each class.
FWIW: one should use the is/as keywords to perform type tests, and most certainly not compare Type.ToString() with some string literal.
is and as translate to a simple IL instruction, and are assumed to be very fast.
PS: if you frequently need dispatching based on type, as in your example, how about using a virtual method/property?
|
|
|
|
|
Luc Pattyn wrote: how about using a virtual method/property?
Due to lack of covariance and contravariance? I think I was just butting my head up against that... again.
|
|
|
|
|
Hey Luc!
Your answer seems to be the most intelligent of the three responses. (Sorry guys)
I have a fairly advanced knowledge of the .Net Framework but there are certain things that Microsoft doesn't explain clearly. For a general developer, I'm sure most of this is unnecessary.
Luc Pattyn wrote: PS: if you frequently need dispatching based on type, as in your example, how about using a virtual method/property?
Cool idea, but I don't think it's my best option for this app.
Cheers!
Richard
If my answer has helped you, one of my articles may also be a help. Also remember that your best friend's name is google.
|
|
|
|
|
Hi Richard,
Richard Blythe wrote: there are certain things that Microsoft doesn't explain clearly
you know, you might be right about that
|
|
|
|
|
Lol, thanks again for the response.
If my answer has helped you, one of my articles may also be a help. Also remember that your best friend's name is google.
|
|
|
|
|
You're welcome.
|
|
|
|
|
Richard Blythe wrote: how much storage space a Type object requires
Assume the worst. If you use Reflection to get such information, it's best to cache what you need.
Richard Blythe wrote: how fast the "is" function is evaluated
You could do a bunch of them and time them.
If you do a lot of that you might be interested in my TypeTransmogrifier[^].
modified on Tuesday, March 30, 2010 3:10 PM
|
|
|
|
|
Hi..
I want to create a line, polygon shapefile.. Pls can someone help...
|
|
|
|
|
Draw a line from A to B.
Draw another line from B to C.
.. repeat ad nauseam to X ...
Draw a line from X to A.
Voila! A polygon.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
U didnt get me actually.
I am using map control. I got this control from the mapwinGIS.
On the mapcontrol i create vector and raster layers...
Vector layer is basically opening shapefiles.
Now i need to create point shapefile, line shapefile.
|
|
|
|
|
I think this site[^] will have the best information.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Hello everybody,
I am using map control to add shapefiles in my project.
I want to add image to the map control and also drag and resize it.
Pls can someone help me...
I am able to place the image on the map control. But not able to drag and resize.
|
|
|
|
|
How are you placing the image? Are you drawing it yourself, or using a PictureBox? How you drag and re-size will be affected.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
I'll have an image file say bitmap file. And am adding it as a lyer on the mapcontrol.. Now i need to edit it or like drag/move it from one position to another and resize it.
Am not using picturebox. Am using mapcontrol. and display my image on that mapcontrol only. u get the map control from mapwindowgis
|
|
|
|
|
How can I get the position of a certain cell of a datagridview. To be specific I don't want the mouse coordinates. Suppose I have a datagridview with Name (ReadOnly), ID and TransDate columns and I want to popup a tiny lookup form when the mouse is clicked or Enter button is pressed when the focus is upon the Name column. The lookup form should openup exactly upon the Name column of the selected row. Thanks.
|
|
|
|
|
You can use CellBeginEdit event for this. Check the current column index and if it is name, show the look up form. You can set the location for the form according to the current cell.
BTW, what EditMode have you set for the DataGridView?
|
|
|
|
|
Here's a solution I came up to.
I am opening a dialog form above the datagridview form. In Form1 I have a datagridview containing few columns among which is 'TransDate' column having index 8. When I click on it, frmDate opens up exactly on it. My revised code follows:
Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridview1.CellClick
If DataGridview1.CurrentCell.OwningColumn.Name = "TransDate" Then
Dim objPoint As Point
'Getting the exact location of the cell with respect to Form1.
'Note- Me.Location is added here alongwith DataGridView1.Location and
'DataGridView1.GetDisplayRectangle().Location.
'This is done because the form frmDate we are calling is external to Form1 and if we don't add
'Me.Location
'here, frmDate won't open exactly at the desired point if we move or resize Form1. Instead of
'frmDate if we use any control inside Form1 to place over 'TransDate' column then remove
'Me.Location here and the next two lines.
objPoint = (Me.Location + DataGridview1.Location + DataGridview1.GetCellDisplayRectangle(8,
DataGridview1.CurrentCellAddress.Y, True).Location)
'Setting the exact location where frmDate will be opened. The last digits may vary according to
'your requirement.
objPoint.X = objPoint.X - 158
objPoint.Y = objPoint.Y + 28
objFrmDate = New frmDate()
objFrmDate.Location = objPoint
objFrmDate.ShowDialog(Me)
objFrmDate = Nothing
End If
End Sub
Regards.
|
|
|
|
|
Hi,
How about enhance it, and make it general to benefit from it more, like this.
this code is in C#.
-------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
namespace MyNamespace
{
public class ControlUtilityClass
{
public static Rectangle Get_DataGridCellLocationAndSize(DataGridViewCell cell)
{
Rectangle result;
Rectangle rec = cell.DataGridView.GetCellDisplayRectangle(cell.ColumnIndex,
cell.RowIndex, false);
Rectangle rec1 = cell.DataGridView.RectangleToScreen(rec);
result = cell.DataGridView.FindForm().RectangleToClient(rec1);
return result;
}
}
}
modified on Wednesday, June 30, 2010 2:09 AM
|
|
|
|
|
DESKTOP APPLICATION.
Hi, below is the problem briefed:
In my home form I have a splitcontainer and few buttons. When the buttons are clicked respective forms are opened in the splitcontainer. The splitcontainer is anchored- top, left, right, bottom so that when the home form is resized the splitcontainer resizes itself automatically. The controls within the other forms are also anchored properly to resize themselves accordingly. But the problem is when i open a form in the splitcontainer, even if I resize the home form, the controls in the form within the splitcontainer aren't resizing. The reason is when the home form is resized the splitcontainer is resizing itself accordingly but the form inside the splitcontainer isn't (as forms don't have anchor or dock properties so I couldn't set them). As a result though the controls in the sub form are anchored to resize themselves yet they aren't. How to solve it.
In short I want the form in the splitcontainer and all the controls in it to resize automatically when the home form/splitcontainer is resized. Regards.
|
|
|
|
|
AFAIK a Form is a Control, and hence has an Anchor property. It will only work when its TopLevel property is set false.
If that does not work, and assuming the Form is resizable, I would add a handler to the SplitContainer's panel, and write the code that resizes the Form it is holding. The Controls inside the Form will then do whatever their designer decided they should do.
|
|
|
|
|
Never mind! I missed a small property. When you call the subform in the splitcontainer of the main form just set the property Dock to Fill.
dim objFrmSubForm as New frmSubForm()
objFrmSubForm.Dock=DockStyle.Fill
objFrmSubForm.Show()
objFrmSubForm=Nothing
Regards.
|
|
|
|
|
User user = FillObject(o);
opContext.AddToUsers(user);
opContext.SaveChanges();
opContext.AcceptAllChanges();
Fill Object is my private method which returns an user object.
Savechanges does not save changes to the database at the same time
does not throw error.
I am using sql express 2008 express edition and visual studio 2010
release candidate. Let me know if some body has the same problem.
Is there any setting on sqlserver express edition which i have to turn on.
The piece of code seems to work when i use sql server 2005 on a different
machine
Any help is greatly appreciated
|
|
|
|
|
EF is really agnostic when it comes to versions, if it works with SQL Server 2005 it will work with SQL 2008, Express or otherwise, so I don't buy that it works with one and not with the other. Try debugging through your code, there is obviously something wrong but without seeing whats in FillObject we can't comment.
I know the language. I've read a book. - _Madmatt
|
|
|
|