Skip to content

C#

C# discussions

This category can be followed from the open social web via the handle c-065f1d12@forum.codeproject.com

93.7k Topics 383.1k Posts
  • does Trim() work??

    data-structures question
    8
    0 Votes
    8 Posts
    0 Views
    C
    James T. Johnson wrote: I try to be really good at what I do, currently that is C# and .NET Thats a good attitude to have ! I hope you succeede ? Regardz Colin J Davies Sonork ID 100.9197:Colin Free Colin Davies "real Americans don't criticize their leaders - because they don't want the terrorists to win." -- Quote from Chris Losinger a real American"
  • kernel32.dll

    question csharp
    9
    0 Votes
    9 Posts
    0 Views
    J
    Christian Graus wrote: Can I *do* this in C# ? I don't think so, I'm pretty sure you'll have to use Managed C++ for this. I'm not sure if you can export a __gc method, but you can export a regular method which calls the __gc one. This is the real power of MC++, you can make calls to both sides easily :) James Simplicity Rules!
  • Connection String

    database help question
    5
    0 Votes
    5 Posts
    0 Views
    M
    Neil Van Note wrote: What is the runtime error? When the messagebox appear,in the place of error message there is no message and its empyt. :( :confused: Mazy "The path you tread is narrow and the drop is shear and very high, The ravens all are watching from a vantage point near by, Apprehension creeping like a choo-train uo your spine, Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
  • Screen mousemove event?

    question
    4
    0 Votes
    4 Posts
    0 Views
    R
    another idea: maybe you can use the MouseEnter and MouseLeave messages each control (and so each form) provides. but if that still isn't your applications clientarea, this helps you only to make the transparent window smaller (so that its client-size fits the rectangle you need to observe), i.e. not the whole screen anymore. :wq
  • get no cursor-key-down-event in mdi-app

    docker question
    4
    0 Votes
    4 Posts
    0 Views
    J
    Rüpel wrote: man, what are you doing? editor for the class-library-documentation? LOL, no nothing quite as nice as that; I just have a knack for remembering programming related things. Unfortunately 90% of the time I can't remember what I said 5 minutes after I say it :-P James Simplicity Rules!
  • C# Code Comments

    csharp visual-studio tools xml help
    4
    0 Votes
    4 Posts
    0 Views
    P
    >>nDoc is EXACTLY (a good start anyway) what I was looking for... I concur, thank you James! :) Is a society built on greed better than a society built on survival?
  • Any way to make a 256 color cursor?

    question discussion
    2
    0 Votes
    2 Posts
    0 Views
    Z
    Finally got it to work. Had to use an outside editor (Michaelangelo)
  • Hotspot for a cursor object

    question
    5
    0 Votes
    5 Posts
    0 Views
    Z
    Well, glad it's not the SlimFast... Little investigation shows that creating a new 'Cursor' actually just creates an Icon instead. You can copy an old cursor into it and change it and then it works (ok). It does NOT support 256 color cursors, only 16 color ones. (ugh).
  • I don't have topic for this

    question
    4
    0 Votes
    4 Posts
    0 Views
    J
    Actually there is an even better way if you are really concerned about performance. class Form1 : System.Windows.Forms.Form { public Form1() { InitializeComponent(); this.Activated += new EventHandler(Activated\_PerformOnce); } private void Activated_PerformOnce(object sender, System.EventArgs e) { this.Activated -= new EventHandler(Activated_PerformOnce); // Do your on form show stuff } } Amazing what comes to you while you sleep :-P James Simplicity Rules!
  • FileAttribute

    question
    3
    0 Votes
    3 Posts
    0 Views
    M
    Thank you,I'll check it as soos as I go home. :) Mazy "The path you tread is narrow and the drop is shear and very high, The ravens all are watching from a vantage point near by, Apprehension creeping like a choo-train uo your spine, Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
  • LogicalDrives

    question
    3
    0 Votes
    3 Posts
    0 Views
    M
    Thank you,I'll check it as soos as I go home. :) Mazy "The path you tread is narrow and the drop is shear and very high, The ravens all are watching from a vantage point near by, Apprehension creeping like a choo-train uo your spine, Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
  • Icon from ImageList

    question learning
    3
    0 Votes
    3 Posts
    1 Views
    D
    Thanks! Based on your suggestion, here's what worked: Icon test = Icon.FromHandle(new Bitmap(imgList.Images[1]).GetHicon()); Thanks again! Derek
  • DataSet: no MoveNext or any indexing at all

    question database help
    3
    0 Votes
    3 Posts
    0 Views
    L
    but i dont have the index and can not change the api i am using. the question is, and remains, how do i get the index of a row in a dataset given a DataRow object, and a DataSet object, and NOT the index of the current RowData object. if i can say dataset.Table().rows[20] and get a DataRow object, shouldnt i be able to easily code dataset.Table().rows[_row.rowID + 1] ? the rowID property shows up in the watch window, but why is private? how do i get to it?
  • Display Text/Dynamic Icons in System Tray?

    help question learning
    2
    0 Votes
    2 Posts
    0 Views
    M
    Hello. Solved it with: // Create Bitmap Bitmap TestBitmap = new Bitmap(16,16,PixelFormat.Format32bppArgb); // Draw whatever you want for (int i=0; i<16; i++) TestBitmap.SetPixel(i,i,Color.Red); // Show as Icon IntPtr PtrIcon = TestBitmap.GetHicon(); this.MyTrayIcon.Icon = Icon.FromHandle(PtrIcon); MyTrayIcon is a "NotifyIcon", Other PixelFormat may be better, This is just a code-snipped... Mario
  • OutlookBar

    help csharp question announcement visual-studio
    7
    0 Votes
    7 Posts
    0 Views
    J
    To create your own control simply create a new class and derive from System.Windows.Forms.Control; or in VS.NET choose to add a new item and choose Custom Control from the box. You can then handle the events you want (overriding OnPaint is going to be one of them :)) Here's a simple control that creates a very lightweight label using System; using System.Drawing; using System.Windows.Forms; public class LightLabel : System.Windows.Forms.Control { public LightLabel() : base() { // Nothing to set here } public override void OnPaint(PaintEventArgs e) { Brush textBrush = new SolidBrush(ForeColor); Brush background = new SolidBrush(BackColor); Graphics g = e.Graphics; g.FillRectangle(background, Bounds); g.DrawString(Text, Font, textBrush, Bounds); textBrush.Dispose(); background.Dispose(); } } I didn't actually compile the code but that is the general idea behind creating your own control. You'll also want to look at the ControlPaint class for lots of cool drawing effects you find on controls (the etched border, drawing a 'disabled' image, etc). If you want to get really fancy with your control you'll need to look at Designers which is something I haven't looked at in-depth yet. James Simplicity Rules!
  • AVI

    csharp c++
    3
    0 Votes
    3 Posts
    0 Views
    M
    I'd say the authorative answer whenever dealing with AVI would be Virtual Dub (Google will tell you).
  • WinForm Datagrid Control

    question learning
    2
    0 Votes
    2 Posts
    0 Views
    J
    For #1 give this a shot // columnIndex must be set to a number. int columnIndex = 1; // remove the second column GridColumnStylesCollection myGridColumns; myGridColumns = dataGrid1.TableStyles[0].GridColumnStyles; myGridColumns.RemoveAt( columnIndex ); For #2 there try this block. GridColumnStylesCollection myGridColumns; myGridColumns = dataGrid.TableStyles[0].GridColumnStyles; foreach(DataGridColumnStyle style in myGridColumns) { // GetColumnWidth takes the header name and returns the width the column should be style.Width = GetColumnWidth(style.HeaderName); } HTH, James Simplicity Rules!
  • F1 Help?

    tutorial csharp help question
    2
    0 Votes
    2 Posts
    0 Views
    J
    Use the HelpRequested event (HelpEventHandler is the delegate instead of HelpRequestedEventHandler). James Simplicity Rules!
  • CButton::GetState in .NET?

    question csharp help
    6
    0 Votes
    6 Posts
    0 Views
    N
    I knew I hadn't been that far off, thanks. :) Nick Parker This is a non-Calculus course as long as you know things like line integrals and surface integrals...
  • Saving class instance to file??

    question
    2
    0 Votes
    2 Posts
    0 Views
    J
    You need to look at something called serialization. Heres a simple example using System; using System.Runtime.Serialization.Formatter.Binary; using System.IO; [Serializable()] public class MyClass { public int MyInt; private int privateInt; public MyClass(int pub, int pri) { MyInt = pub; privateInt = pri; } public void PrintOut() { Console.WriteLine("MyInt = {0}, privateInt = {1}", MyInt.ToString(), privateInt.ToString()); } } public class Driver { public static void Main() { MyClass myClass = new MyClass(4, 2); // Save the instance to a file FileStream stream = new FileStream("C:\\\\myclass.bin", FileMode.CreateNew, FileAccess.Write); IFormatter formatter = new BinaryFormatter(); // Actually does the saving formatter.Serialize(myClass); // Close the file stream.Close(); // Set MyClass to null so that there are no handles to it anymore myClass = null; // Read the instance from the file stream = new FileStream("C:\\\\myclass.bin", FileMode.Open, FileAccess.Read); // Actually create the class instance from the file myClass = (MyClass) formatter.Deserialize(stream); // Close the stream stream.Close(); // Show that all data was saved, public AND private myClass.PrintOut(); } } If you want to customize what is saved in the serialization process refer to the documentation on the ISerializable interface HTH, James Simplicity Rules!