|
You're welcome.
______________________________
The Tao gave birth to machine language.
Machine language gave birth to the assembler.
The assembler gave birth to ten thousand languages.
Each language has its purpose, however humble.
Each language expresses the Yin and Yang of software.
Each language has its place within the Tao.
Beauty exists because we give a name to C#.
Bad exists because we give a name to COBOL.
|
|
|
|
|
I have a couple of questions about list box scrolling:
1. How you handle scroll events?
2. How do you get and set scroll positions?
Gary Kirkham
A working Program is one that has only unobserved bugs
He is no fool who gives what he cannot keep to gain what he cannot lose. - Jim Elliot
Who you are in Christ
|
|
|
|
|
Extend the class, override WndProc , and handle WM_HSCROLL (0x0114) and WM_VSCROLL (0x0115). I suggest defining two events and their virtual handlers (VScroll event fired by OnVScroll handler, and HScroll event fired by OnHScroll - the recommended way of defining events) and fire those along with any data you want in your WndProc override.
To set the position, you P/Invoke SendMessage and send those messages to your control's HWND (window handle, exposed by the Handle property). Note that when setting the position, you must also update the scrollbar position information by P/Invoking SetScrollInfo . Why and what you should pass is documented on MSDN[^] if you lookup WM_VSCROLL .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
When I try to make and test it in server explorer, this error message has shown:
Test connection failed because of an error in initializing provider. Cannot start your application.
The workgroup information file is missing or opened exclusively by another user.
Database was closed.
|
|
|
|
|
If you read the documentation for Access, you'd see that a workgroup file is an .mdw file (IIRC, it's been a while). There is a system default installed in the installation directory for Access, but if a particular .mdb file (Jet Database) uses unique credentials, it will have a different .mdw file (typically in the same directory). I don't remember what the connection string property is called (and those Access docs will tell you), but you must include that property and the fully-qualified path to the .mdw file, as well as credentials (User ID and Password) that are defined in that .mdw file in order to access the .mdb database.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
i'm trying to simulate what ping.exe does and send ICMP packets to a host. how can i do this in .net?
|
|
|
|
|
|
You could make your own using raw sockets and the ICMP protocal. But you don't have to becaue there is already a class to do it for you.
Icmp Class[^]
/\ |_ E X E GG
|
|
|
|
|
like others have suggested, u can use RawSockets and ICMP protocol type, or use an existing class like the one eggie5 has suggested.
Be aware that not all machines respond to ICMP echo request (which is what PING uses), and many firewalls might treat lots of ICMP echo request as an attack. The question is what are you trying to simulate? if you're in control of the host, have you considered using UDP?
|
|
|
|
|
Hi,
can anyone help me converting vb.net code given below into c#. I tried some converting tools but it will put the same code in c# and will give reference to Microsoft.VisualBasic.Compatibility, but i don't want that. i want the c# code for this method without using the reference to Microsoft.VisualBasic.Compatibility, also, if i have .dll project, how do i convert the .dll executable at the same time.. i appreciate ur help. Thanks...
vb.net code
-------------
Private Function GetSingleProperty(ByRef sElementName As String) As String
Dim vValues As Object
vValues = g_pPropSet.GetProperty(sElementName)
If IsNothing(vValues) Then
GetSingleProperty = ""
ElseIf VarType(vValues(LBound(vValues))) <> VariantType.String Then
GetSingleProperty = ""
Else
GetSingleProperty = vValues(LBound(vValues))
End If
End Function
vijju
|
|
|
|
|
You've already asked this question not more than an hour ago - be patient. See my reply, because you seem to be missing a key feature of the .NET Framework - the fact that it doesn't matter in what language the source was written because the assemblies all contain IL (unless they're mixed mode, which currently only MC++ supports (from the Microsoft camp)).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi Heath,
thanks for replying. actually i am not very good at vb, but i am a little comfortable programming with c#. that is one reason i wanted to convert that code into c#. also, i wanted to know more about coupling and de-coupling, if i want to run my .dll project (which is going to be plug-in) as an executable at the same time. if you suggest any examples or material to follow-up the understand the architecture design, that will be GREAT. and also i didn't knew that my question was posted more than one time, and sorry about that..
Thanks
vijju
|
|
|
|
|
Coupling and decoupling has nothing to do with how code is executed - it has to do with how code is referenced.
Knowing the C# language doesn't mean you know .NET. If you want to learn more, I suggest you read the SDK, which should be installed on your machine (it is installed by default with VS.NET, but can be installed separately) and available online at http://msdn.microsoft.com/library/en-us/dnanchor/html/netfxanchor.asp[^]. Understanding at least the basic concepts of the CLR (like what assemblies are) is important.
Since you didn't tell me what g_pPropSet is defined as, I can only assume it's defined in the Microsoft.VisualBasic.Compatibility assembly. As I mentioned before - converting the code isn't a good idea, especially if you're new to .NET; you'll never learn anything that way. So, just converting the code to C# won't get rid of the assembly dependency - you'll have to rewrite it to use a similar class. Judging by what you seem to be trying to do, a suitable class might be the StringDictionary as I mentioned in my other reply.
If you want to know more about architecting .NET solutions, visit http://msdn.microsoft.com/patterns[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Besides, do you maybe want to put this in context? What are you trying to do? Extract a value from a collection? If all you did was convert from one language to another, you're constrained by what the rest of the code did.
Now, if you convert the concept, you could use many types to do this. For example, you could use a Hashtable or StringDictionary (or several other things in the BCL) to store string key/value pairs and refer to them by name:
StringDictionary dict = new StringDictionary();
dict["One"] = "Apple";
dict["Two"] = "Orange";
dict["Three"] = "Banana";
Console.WriteLine(dict["Two"]); When moving from one application framework to another, don't just convert your code. Advancements are made with newer frameworks. If all you're doing is porting your code just to run on the .NET Framework, you're doing a very stupid thing (any article by a decent author will tell you as much) - if it works, don't change it. If you have to change it to add new functionality later and to be maintainable by less-than-knowledge programmers, then change it in steps.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
My VB is a bit rusty but I think this is your answer.
private string GetSingleProperty(string elementName)
{
object Values = g_pPropSet.GetProperty(elementName);
if (Values == null)
return String.Empty;
if (Values.GetType() != typeof(String))
return String.Empty;
return (string)Values;
}
|
|
|
|
|
That would still require the Microsoft.VisualBasic.Compatibility assembly, since whatever Type g_pPropSet seems to be from there (since everything else is defined in the BCL assemblies). He doesn't want to reference that assembly, even though it really doesn't matter.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
how do we get our column width auto adjusted to fit the length of the column header text when it's displayed in dataGrid.
Thanks
|
|
|
|
|
There is no automatic adjustment for the DataGrid like there is for the ListView (not data-bindable). You must either guess at design-time, or when the DataGrid is loading, enumerate the DataGrid.TableStyles collection property, and enumerate each's GridColumnStyles collection property. Get the text and use Graphics.MeasureString using the Font property of the DataGrid . Set the current column's Width accordingly.
This only works when 1) you're using explicitly defined table and column styles before data is bound, or 2) after data is bound to the DataGrid .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi everyone.
I have an add-in that saves Outlook messages in a customer database.
I've created a toolbar button that's loaded in the Word E-mail toolbar and in the Outlook Standard toolbar. Everything works great in Outlook, but when I open up a new message (Word, that is) I can't get the information from the mail fields, for example "to" and "bcc".
This code gives me the message content:
Word.Document doc = ((Word.Application)myApp).ActiveWindow.Document;
System.Windows.Forms.MessageBox.Show(doc.Content.Text);
So I thought that
Outlook.MailItemClass mail = (Outlook.MailItemClass)doc.MailEnvelope.Item;
should give the mail information I'm looking for, but nope.
How do I find the mail information?
Cheers,
Sven
|
|
|
|
|
Hi,
can anyone help me converting vb.net code given below into c#. also, if i have .dll project, how do i convert the .dll executable at the same time.. i appreciate ur help. Thanks...
vb.net code
-------------
Private Function GetSingleProperty(ByRef sElementName As String) As String
Dim vValues As Object
vValues = g_pPropSet.GetProperty(sElementName)
If IsNothing(vValues) Then
GetSingleProperty = ""
ElseIf VarType(vValues(LBound(vValues))) <> VariantType.String Then
GetSingleProperty = ""
Else
GetSingleProperty = vValues(LBound(vValues))
End If
End Function
vijju
|
|
|
|
|
Why bother? Are you forgetting that all managed languages compile down to Intermediate Language? The source language doesn't matter; the associated compilers compiles that to IL and assemblies it in a module, which then gets embedded into an assembly along with embedded resources (if any). So why bother redoing it in C#? Just have your C# project reference the VB.NET assembly and viola'! The BCL (base class library) assemblies are written in C#, but you can use them in VB.NET, MC++, J#, and all the other languages, can't you?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Help! Help! Help!
I have a usercontrol that have a collection contain of a class(or struct). I want the collection be save autamatically with form's code.
my code:
public class Struct1<br />
{<br />
private int m_x ;<br />
public int x <br />
{<br />
get{return m_x;}<br />
set{m_x=value;}<br />
}<br />
private string m_y ;<br />
public string y <br />
{<br />
get{return m_y;}<br />
set{m_y=value;}<br />
}<br />
}<br />
private Struct1 m_struct ;<br />
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]<br />
<br />
public Struct1 STRUCT<br />
{<br />
get{return m_struct ;}<br />
set{m_struct=value;}<br />
}<br />
<br />
public class MyCoulumnClollectionClass : CollectionBase<br />
{<br />
<br />
public Struct1 this[ int index ] <br />
{<br />
get <br />
{<br />
return( (Struct1) List[index] );<br />
}<br />
set <br />
{<br />
List[index] = value;<br />
}<br />
}<br />
public int Add( Struct1 value ) <br />
{<br />
return( List.Add( value ) );<br />
}<br />
<br />
public int IndexOf( Struct1 value ) <br />
{<br />
return( List.IndexOf( value ) );<br />
}<br />
<br />
public void Insert( int index, Struct1 value ) <br />
{<br />
List.Insert( index, value );<br />
}<br />
<br />
public void Remove( Struct1 value ) <br />
{<br />
List.Remove( value );<br />
}<br />
<br />
public bool Contains( Struct1 value ) <br />
{<br />
return( List.Contains( value ) );<br />
}<br />
}
|
|
|
|
|
How many more times must I say, that if the DesignerSerializationVisibilityAttribute isn't giving you the effect you want, you will have to derive your own CodeDomSerializer and reference your implementation in the DesignerSerializerAttribute that would attribute your collection property? Those are your only two options, the the one option obviously doesn't work. Do the math.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi.
Thank you.
But i try to using CodeDomSerializer , but it is failed.
|
|
|
|