Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
P

petercrab

@petercrab
About
Posts
8
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Proper way to determine the colors of controls?
    P petercrab

    Gif supports transparency, can't you make the background transparent in your gif images? Would this do what you need?

    C# question database data-structures regex

  • Multi-color text in single cell of datagridview in C#
    P petercrab

    Hi, You need to override the paint method for the cell object. Cells that contain just text are instances of DataGridViewTextBoxCell Class, so override that. Below is my attempt at a new class with over-ridden paint method. The draw method also only draws what will fit in cell so there will be no overlapping of data between cells. I have tried to make it as reusable as possible so you can define what colour you wish to change to and the number of consecutive numbers that should have colour changed. I also include code I used to test the class out and a couple of screenshots showing it working.

    public class MultiColourDataGridViewTextBoxCell : DataGridViewTextBoxCell
    {
    public MultiColourDataGridViewTextBoxCell():base()
    {
    }

        /// <summary>
        /// overide paint method to colour text dependant on number of consecutive numbers
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="clipBounds"></param>
        /// <param name="cellBounds"></param>
        /// <param name="rowIndex"></param>
        /// <param name="cellState"></param>
        /// <param name="value"></param>
        /// <param name="formattedValue"></param>
        /// <param name="errorText"></param>
        /// <param name="cellStyle"></param>
        /// <param name="advancedBorderStyle"></param>
        /// <param name="paintParts"></param>
        protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            int fontSize = 9;
            Brush textBrush = Brushes.Green;
            Font font = new Font(FontFamily.GenericSansSerif,fontSize,FontStyle.Regular);
            String stringPrint = (String)formattedValue;
    
            graphics.FillRectangles(Brushes.White,new Rectangle\[\]{cellBounds});
            StringPrintInfo\[\] stringPrintInfo = GetConsectiveNumbers(4, stringPrint, Brushes.Black, Brushes.Red);
            PrintConsectiveNumbers(stringPrintInfo,graphics, font,textBrush,cellBounds,StringFormat.GenericDefault);
            this.PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
    
    C# csharp json tutorial question

  • A Couple of Questions
    P petercrab

    Sound like Excel. Can you not achieve this with Microsoft Excel and macros or other spreadsheet app. Please confirm if Excel is available to you. A C# solution to this could use VSTO(Visual Studio Tools for Office) api

    C# help tutorial question

  • C# test if number exists in array and if not put it in
    P petercrab

    I would definitely use a List(dynamic array) for what you want.

        List<int> numbers = new List<int>();
    
        private bool RndDuplicate(int intRnd)
        {
            if (numbers.Contains(intRnd))
                return true;
            else
            {
                numbers.Add(intRnd);
                return false;
            }
        }
    
    C# csharp database data-structures

  • I want to modify/replace some data from a binary file without loadig the file in memory.
    P petercrab

    what you have written already looks ok to me. Like others have said, so long as binary file is not too large you can get a speed increase by loading entire file to memory in one read, modifying, then writing the output file. many thanks, petercrab

    C# database performance

  • Abstracts: can I do better than this?
    P petercrab

    looks fine to me.

    C# question

  • Invoke a function every time that a function is been added to my event
    P petercrab

    hi, I am not sure how to call method every time you add to a delegate. Why don't you call the method after the delegate is added . e.g MyFunction += new DoItDelegate(DoItFunction); RegisterTheNewMethod();

    C# question com tutorial

  • breaking a string to substrings
    P petercrab

    hi, I did this using regular expressions. I wrote a method to split a string by alphabetic characters. 14p gives array of one item 14 14eur gives an array of one item 14 14eur14pp15p gives an array of 3 items 14, 14, and 15 http://pastebin.com/f55499ed[^]

    modified on Wednesday, December 30, 2009 2:56 AM

    C# question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups