|
Or better yet, cast to Control, which has that property and is more 'guarenteed'.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Ok, that's right for a control but, if it isn't, and it's an object instanciated from a class library that after doing this cast doesn't have the Name property, how could I know it?
Thanks,
Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
I think you know that the answer to your question is NO, not by the way already mentioned; however, what I understood you are saying is, in general, all objects will have some name, how can you get access to that name?
If that is the question, then I think that the only way is to check for the object type and access its name by the method appropriate to that object type.
for e.g., maybe you need to use reflection to get the class name OR
you can get the type name which should be the class name - I am not sure. Just my thoughts.
Shreekar
|
|
|
|
|
Using reflection I just can get the class name/type. What I'm looking for is its name that, even it's not a control, I have instanciated an object as a class type and with a name. Isn't there any way to retrieve it?
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
Marc Soleda wrote: Using reflection I just can get the class name/type
No, using reflection you can find properties and you can get their values.
Marc Soleda wrote: I have instanciated an object as a class type and with a name.
If you mean the variable name, you can't get it. If you mean a property on the control, you can get it with reflection, but if you don't know what the variable name is, then you're going to have a hard time.
An event handler is always going to have a control come in, I assume you mean the question more generally. It's unusual for your code to take an object and for you to have *no* idea what the object will be.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Christian Graus wrote: An event handler is always going to have a control come in...
Not always if it's an object's class - not a control - that raises an event when a something happens: I file has been received, ...
Christian Graus wrote:
It's unusual for your code to take an object and for you to have *no* idea what the object will be.
Unusual maybe but If I handle an event from several objects in only one eventhandler, then I need to differenciate between them to know which one has been.
At last, I've solved by using Object.ReferenceEquals that determines if two objects are the same instance.
Thanks,
Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
Try
If sender.name="A Name" Then
'Do A Task
End If
Catch ex As Exception
MsgBox("The object dosn't support name property")
End Try
|
|
|
|
|
Marc Soleda wrote: Ok, that's right for a control but, if it isn't, and it's an object instanciated from a class library that after doing this cast doesn't have the Name property, how could I know it?
You can't, as it doesn't have a name.
What you are looking for is the name of the variable the holds the reference to the object. The problem is that there can be more than one variable referencing the object, or if there is a single variable, that variable might not have a name either, e.g. if it's part of an array.
---
Year happy = new Year(2007);
|
|
|
|
|
Guffa wrote: You can't, as it doesn't have a name.
That's the key! It doesn't have a name but I can compare two objects to know if they are the same instance that, for my purposes, is what I need: Object.ReferenceEquals
Thanks,
Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
You could also try:
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
Dim Ctrl As Control<br />
For Each Ctrl In Me.Controls<br />
If Ctrl.GetType Is sender.GetType Then MsgBox(Ctrl.Name.ToString)<br />
Next<br />
End Sub<br />
As a small concern, I would like to ask you this, are you sure that you are not trying to take efficient coding a bit too far?
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Johan Hakkesteegt wrote: As a small concern, I would like to ask you this, are you sure that you are not trying to take efficient coding a bit too far?
In this context maybe, but I want to export this to a class library made by me and it would help a lot if we could handle some events in this way.
Thanks,
Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
Hi,
I dont know how to insert and retrive the image from the sqlserver2000 by using vb.net..im having the coding of c sharp.net but i dont know how to convert into vb.net, could anybody help me plz..
C sharp coding as follows for insertion and retrival...
private void BUpload_Click(object sender, System.EventArgs e)
{
// Create a byte[] from the input file
int len=FUpload.PostedFile.ContentLength;
byte[] pic = new byte[len];
FUpload.PostedFile.InputStream.Read(pic,0,len);
try
{
connection.Open ();
SqlCommand cmd = new SqlCommand ("insert into img "
+ "(bImg) values (@bImg)", connection);
cmd.Parameters.Add ("@bImg", pic);
cmd.ExecuteNonQuery ();
}
finally
{
connection.Close ();
}
}
==================
private void BShow_Click(object sender, System.EventArgs e)
{
MemoryStream stream = new MemoryStream ();
try
{
connection.Open ();
SqlCommand command = new
SqlCommand ("select bImg from img", connection);
byte[] image = (byte[]) command.ExecuteScalar ();
stream.Write (image, 0, image.Length);
Bitmap bitmap = new Bitmap (stream);
Response.ContentType = "image/jpeg";
bitmap.Save (Response.OutputStream, ImageFormat.Jpeg);
}
finally
{
connection.Close ();
stream.Close ();
}
}
=======================
i need this coding into vb.net help me plz......
regards
Kanna...
|
|
|
|
|
|
hi
i am working on vb.Net 2005,i want to import system.windows.input classes. i read on microsoft site that i have to reference presentationcore.dll in my application which is in Framework 3.0,i installed framework 3.0 but i am unable to find presentationcore.dll,if anyone have any idea so please help me.
Thanks
Thanks
|
|
|
|
|
i Need some help to generate an application which can generate BARCODE as an image..... i want to do it in VB.NET....
if any one have any idea about it..plz help me with this problem.....if u have any demo projects plz send it to this mail address
"abhilash.asokan@gmail.com"
|
|
|
|
|
Free Barcode Font - Code 39 - TrueType - Download
http://www.bizfonts.com/free
|
|
|
|
|
To get examples, type Barcode in the search field at the top of this page, if you can't find the answer there, chances are it can't be done.
"you can't forget something you never knew..." M. Du Toit
"Watching Migthy Joe Young made me hate my life..................................I want a gorilla!" A. Havemann
|
|
|
|
|
How would you get a message box to have a "Get Help" button that will open a document in the folder "Help" within the folder that the application is stored when you press it?
Also, I would like a custom icon as well (in the same location as the VS logo in this error below.)
Similar to this one
http://www.littlecatdevelopment.com/blog/vberror.JPG[^]
How would you create a custom message box as a library class so i could use it over again?
Any help would be nice
In the end we're all just the same
|
|
|
|
|
You would just create a brand new form, design it any way you like, and use it. You can put it in a dll if you want to, but that seems overkill.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
My DataTable has a VarChar field with no default value and it does not allow Nulls.
This DataTable is bound to my form using a BindingSource.
For some this reason when I do a BindingSource.EndEdit , that field is cleared, meaning the value the user entered into the textbox becomes cleared, and an exception is thrown stating that this field does not allow NULLS.
This makes absolutely NO sense, why would the EndEdit physically edit the value of one of my controls? And why change it to NULL if the field is required?
-- modified at 7:21 Thursday 1st February, 2007
"you can't forget something you never knew..." M. Du Toit
"Watching Migthy Joe Young made me hate my life..................................I want a gorilla!" A. Havemann
|
|
|
|
|
Hi all, I have a form in which I load a .rpt file, populate som values and then export it into a .PDF file. Something goes seriously wrong here thou.
All occurances of the letter t is replaced with ti or tt. All occurances of ti is being replaced
with tt. So for an example out of the file.
Should be Becomes after export to Adobe PDF
---------------------------------------------------------
Mattias Mattas
kommentarer kommentiarer
Deviation Deviatton
Skadat Skadatt
Registrerat Registirerati
I dunno why it does this. Has anyone else been out for it or am I alone in this matter?
Below is the "export" part of the code
<br />
CrystalReportViewer1.ReportSource = rptDocument<br />
<br />
<br />
Me.rtStatus.AppendText("Exporting to PDF" & vbCrLf)<br />
Application.DoEvents()<br />
<br />
Dim CryRepExportoptions As New CrystalDecisions.Shared.ExportOptions<br />
Dim CryRepDestination As New CrystalDecisions.Shared.DiskFileDestinationOptions<br />
Dim CryRepTypeOptions As New CrystalDecisions.Shared.PdfRtfWordFormatOptions<br />
<br />
CryRepDestination.DiskFileName = IO.Path.GetDirectoryName(Reflection.Assembly.GetExecutingAssembly.Location) + "\PDFTemp\" & Ticket.ToString & ".pdf"<br />
CryRepExportoptions = rptDocument.ExportOptions<br />
<br />
With CryRepExportoptions<br />
.ExportDestinationType = ExportDestinationType.DiskFile<br />
.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat<br />
.DestinationOptions = CryRepDestination<br />
.FormatOptions = CryRepTypeOptions<br />
End With<br />
<br />
rptDocument.Export()<br />
<br />
I'm completely clueless in this matter. Any help would be greatly appreciated. ![Smile | :)](https://codeproject.freetls.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
hello,
i ve got a problem, where i have two asp pages say "A" and "B".
"A" and "B" are two differnet applications running on two different browsers on a same PC.
clicking a link on page "A" should check whether "B" is already running on that PC or not.
if yes then pass some parameter to page "B".
if no then create a new instance of page "B" in a new browser and pass parameters.
A help would be greatly appreciated.
Manas
|
|
|
|
|
Didn't you ask this using a different account the other day ?
You can't do it. A web browser cannot iterate over other browser instances that are running, it can't question them about where they are browsing. At least, not using javascript, AFAIK.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Probably you should look at opening a new window with a predefined name - this is all javascript:
var w = window.open("B" with params,"BWindow");
AFAIK, this will re-use the window with the same name if already open with the passed URL.
But remember that effectively, you are firing a new request to the server when you add the params.
Hope this helps.
Shreekar
|
|
|
|
|
That will obviously work, but I understood that he wants to find application B, no matter where it was previously opened from
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|