User Profile

Collapse

Profile Sidebar

Collapse
jjvainav
jjvainav
Last Activity: Mar 23 '08, 04:36 PM
Joined: Feb 28 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • The array is allocated on the heap. But really, you can't think of the .NET heap the same way as in C or C++. Allocating a new object on the heap CAN be, but not always, faster then allocating memory on the stack in .NET.

    When a .NET application starts, a chunk of memory is allocated as the heap. So the memory is already allocated, when an object is created with the 'new' keyword, that object is given preallocated memory on the .NET...
    See more | Go to post

    Leave a comment:


  • jjvainav
    replied to byte array to struct
    in .NET
    That object is an object of type you want to cast your byte array to. There is another way so you don't need that object.

    Code:
    static object ByteArrayToStructure(byte[] bytearray)
    {
      IntPtr ptr = IntPtr.Zero;
    		
      try
      {
        ptr = Marshal.AllocHGlobal(bytearray.Length);
        Marshal.Copy(bytearray, 0, ptr, bytearray.Length);
    				
        return Marshal.PtrToStructure(ptr,
    ...
    See more | Go to post

    Leave a comment:


  • jjvainav
    replied to label position
    in .NET
    The label control does have the properties Left and Top. They are hidden from the designer. You can also do it this way:

    Code:
    label1.Location = new Point(100, 50);
    ...
    See more | Go to post

    Leave a comment:


  • Try this:

    Code:
    Public Class Form1
        Private Delegate Sub SetTextCallback(ByVal text As String)
    
        Private form2 As Form2
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            form2 = New Form2
            form2.Show()
            form2.BringToFront()
            signal = New Class1()
        End Sub
    ...
    See more | Go to post

    Leave a comment:


  • The best approach to this would be to create an event in Class1 that gets raised whenever you want to indicate progress from your thread.

    Code:
            For i As Integer = 0 To 5
                Threading.Thread.Sleep(5000)
                ' Form2.Label1.Text = i.ToString
                ' singal event here
            Next
    Then from your Form1 class you can handle the event and then set your label...
    See more | Go to post

    Leave a comment:


  • jjvainav
    replied to Windows form - Label
    in .NET
    Here is another way you can do this without using the Controls.Find method:

    Code:
    string labelToHide = "Label" + ind;
    if(this.Controls.ContainsKey(labelToHide))
    {
        this.Controls[labelToHide].Visible = false;
    }
    A word of caution, the this.Controls.C ontainsKey method does not do a recursive search like the Controls.Find method does. So if your labels are added to a container,...
    See more | Go to post

    Leave a comment:


  • jjvainav
    replied to Please solve the error below
    in .NET
    This indicates that Me.cbDefault is a ComboBox and the property NewIndex doesn't exist for Me.cbDefault.

    I am not sure exactly what you are trying to do, but if you want to get the index for the selected item in the combobox, change it to:

    Code:
    If Default_Renamed = True Then
    				
           ListIndex = Me.cbDefault.SelectedIndex
    ...
    See more | Go to post

    Leave a comment:


  • jjvainav
    replied to windows registry
    in .NET
    The following should open your dataManage folder and add the key-value pairs.

    Code:
    RegistryKey local = Registry.LocalMachine;
    local = local.OpenSubKey("SOFTWARE\\dataManage", true);
    local.SetValue("emp", "dipa");
    local.SetValue("id", 23);
    local.SetValue("add", "mum");
    ...
    See more | Go to post

    Leave a comment:


  • jjvainav
    replied to Class Library Protection
    in .NET
    Also, any classes/functions that are declared internal can't be accessed outside of that assembly.
    See more | Go to post

    Leave a comment:


  • jjvainav
    replied to Reading .doc file
    in .NET
    Look here:
    http://www.vbdotnetheaven.com/Upload...dDocument.aspx...
    See more | Go to post

    Leave a comment:


  • jjvainav
    replied to Retrieving Identity field
    in .NET
    Right after you do your insert you can do:

    Code:
    INSERT INTO tblOrders (custname, custdetails, orderdate) VALUES (@custname, @custdetails, @orderdate) SET @OrderID = SCOPE_IDENTITY()
    See the following link for a detailed example:
    http://davidhayden.com/blog/dave/arc...2/16/2803.aspx...
    See more | Go to post

    Leave a comment:


  • jjvainav
    replied to Embedded HTML in WINFORMS?
    in .NET
    There is a WebBrowser control that should be in your Toolbox under Common Controls in VS. You can pass some URL or you could store your HTML to a local file, and then pass the local path as the Uri of the WebBrowser control.
    See more | Go to post

    Leave a comment:


  • This should get you started

    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    
    namespace WindowsApplication2
    {
    	public class Form1 : Form
    	{
    		private System.Windows.Forms.StatusStrip statusStrip1;
    		private System.Windows.Forms.ToolStripProgressBar
    ...
    See more | Go to post

    Leave a comment:


  • You will have to make EPType public. However, you can prevent assemblies outside of that one from inheriting your base type, by making an internal constructor.

    Code:
    public abstract class EPType
        {
            private String m_Name;
            public String Name
            {
                get { return m_Name; }
            }
            internal EPType(String Name)
            {
    ...
    See more | Go to post

    Leave a comment:


  • jjvainav
    replied to embed an pdf into .net application
    in .NET
    Unfortunetly the Acrobat Reader ActiveX is very limited. You can however hide the toolbars:

    Code:
    axAcroPDF1.setShowToolbar(false);
    See more | Go to post

    Leave a comment:


  • jjvainav
    replied to Creating a method in C# (2.0)
    in .NET
    I am not sure if this will help, but based on the example above, you need to write it as:

    Code:
    int a = 10;
    string b = "test";
     
    public string MyMethod(object o){
       // get the object and add 1;
        return o.ToString() + "1";
    }
     
    string output1 = MyMethod(a); // 101
    string output2 = MyMethod(b); // test1
    ...
    See more | Go to post

    Leave a comment:


  • jjvainav
    replied to Serialize Object by Object
    in .NET
    That is the thing with the BinaryFormatter , it reads the entire stream that is provided to the Deserialize function. So you would have to write blocks of bytes from a file to a MemoryStream and pass that to the BinaryFormatter ....
    See more | Go to post

    Leave a comment:


  • He is correct, you don't need the BinaryReader. You can simply do:

    Code:
    using(FileStream fs = new FileStream(filePath, FileMode.Open))
    {
        byte[] buffer = new byte[fs.Length];
        fs.Read(buffer, 0, fs.Length);
    }
    ...
    See more | Go to post

    Leave a comment:


  • jjvainav
    replied to Cross-thread operation not valid
    in .NET
    The FileSystemWatch er runs on a seperate thread, when you try to set the value of your TextBox .NET doesn't allow you to access the control from another thread, and will throw the exception you just specified.

    What you need to do is call back to the main thread that your UI is running on. Here is an example on how you can accomplish this.

    [CODE=vbnet]
    Private Delegate Sub FileWatcherCall back(ByVal e As FileSystemEvent Args)...
    See more | Go to post
    Last edited by Plater; Feb 28 '08, 02:29 PM. Reason: code=vbnet, makes it colorized

    Leave a comment:


  • jjvainav
    replied to Serialize Object by Object
    in .NET
    You will somehow need to know the byte length of each object serialized in your file, I am assuming you are using binary serialization. The problem with this is each searialized object won't have the same byte length if you are serializing non-fixed length objects such as strings.

    If you want everything in a single file, you can serialize your object into a MemoryStream, figure out the length, write the first 4 bytes in your file...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...