Click here to Skip to main content
15,887,267 members
Home / Discussions / C#
   

C#

 
AnswerRe: funcions in C# Windows form [modified] Pin
DaveyM6923-Apr-10 22:04
professionalDaveyM6923-Apr-10 22:04 
AnswerRe: funcions in C# Windows form Pin
#realJSOP24-Apr-10 0:50
mve#realJSOP24-Apr-10 0:50 
AnswerRe: funcions in C# Windows form Pin
joey_go24-Apr-10 18:49
joey_go24-Apr-10 18:49 
QuestionNeed help with Icon/Image Resource in C# VS 2008 .Net 3.5 Pin
USAFHokie8023-Apr-10 12:03
USAFHokie8023-Apr-10 12:03 
AnswerRe: Need help with Icon/Image Resource in C# VS 2008 .Net 3.5 Pin
Henry Minute23-Apr-10 13:54
Henry Minute23-Apr-10 13:54 
QuestionAT Commands Pin
Wamuti23-Apr-10 11:59
Wamuti23-Apr-10 11:59 
AnswerRe: AT Commands Pin
joey_go23-Apr-10 15:55
joey_go23-Apr-10 15:55 
QuestionCheckbox on the header of a Listview Pin
Natural_Demon23-Apr-10 11:00
Natural_Demon23-Apr-10 11:00 
i have made this piece of code, to a checkbox on the header:
wel not realy on the headr, but situated there.
(class ColumnHeader doesn't provide much, like for example: OnpaintEvent.

but i need some help with the special effects.

if you hoover the mouse over the header, the mousehover effect of the header hides the checkbox, bringing it to the background.

i would like to have the checkbox ontop @ all time.
using windows 7.


<code>
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace Listview_Colum_header_checkbox
{
    class CCehckBox : CheckBox
    {
        public CCehckBox()
        {
            Width = 14;
            Height = 14;
            //a
            //ValidationConstraints.Visible
            //AutoValidate.EnablePreventFocusChange;
        }

        protected override void OnPaint(PaintEventArgs pevent)
        {
            Invalidate();
            base.OnPaint(pevent);
        }
    }

    class CListViewHeader : ColumnHeader
    {
        void CListViewHeader()
        {
        }
    }

    class CListview : ListView
    {
        private readonly CCehckBox _cCehckBox = new CCehckBox();
        private readonly ColumnHeader _header1 = new ColumnHeader();
        private readonly ColumnHeader _header2 = new ColumnHeader();
        private readonly ColumnHeader _header3 = new ColumnHeader();

        #region  PInvoke Declarations

        [DllImport("user32")]
        private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

        #endregion

        public CListview()
        {
            View = View.Details;

            _header1 = Columns.Add("Name");
            _header1.Width = (Location.X + 5) + 6;
            _header1.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
            _header1.Name = "CheckBox";
            _header1.DisplayIndex = 0;

            _header2 = Columns.Add("bah");
            _header2.Width = (Width - 20) - 50;

            _header3 = Columns.Add("boh");
            _header3.Width = 50;

            var wijd = _cCehckBox.Width;
            var hoog = _cCehckBox.Height;
            _cCehckBox.Location = new Point(Location.X+ 5, Location.Y + 5);
        }


        protected override void OnColumnWidthChanged(ColumnWidthChangedEventArgs e)
        {
            
            if(e.ColumnIndex == 0)
            {
                //MessageBox.Show(e.ColumnIndex.ToString());
                //_header1.ListView.AllowColumnReorder = false;
                //_header1.ListView.CausesValidation = false;

                _header1.Width = (Location.X + 5) + 6; 
                _cCehckBox.BringToFront();
                //Invalidate();
            }
            base.OnColumnWidthChanged(e);
        }

        protected override void OnHandleCreated(EventArgs e)
        {
            SetParent(_cCehckBox.Handle, Handle);
            base.OnHandleCreated(e);
        }
    }
}

</code>

Bad = knowing 2 much

AnswerRe: Checkbox on the header of a Listview Pin
Ravi Bhavnani23-Apr-10 15:37
professionalRavi Bhavnani23-Apr-10 15:37 
GeneralRe: Checkbox on the header of a Listview Pin
Natural_Demon23-Apr-10 16:15
Natural_Demon23-Apr-10 16:15 
Questionvb.net to c# Pin
toto_201023-Apr-10 7:35
toto_201023-Apr-10 7:35 
AnswerRe: vb.net to c# Pin
Luc Pattyn23-Apr-10 7:41
sitebuilderLuc Pattyn23-Apr-10 7:41 
AnswerRe: vb.net to c# Pin
#realJSOP23-Apr-10 7:46
mve#realJSOP23-Apr-10 7:46 
GeneralRe: vb.net to c# Pin
AspDotNetDev23-Apr-10 15:14
protectorAspDotNetDev23-Apr-10 15:14 
GeneralRe: vb.net to c# Pin
toto_201023-Apr-10 23:41
toto_201023-Apr-10 23:41 
QuestionBeginner Question: Distributing Data Driven Applications Pin
Kris Traughber23-Apr-10 4:59
Kris Traughber23-Apr-10 4:59 
AnswerRe: Beginner Question: Distributing Data Driven Applications Pin
dan!sh 23-Apr-10 5:06
professional dan!sh 23-Apr-10 5:06 
GeneralRe: Beginner Question: Distributing Data Driven Applications Pin
Kris Traughber23-Apr-10 5:22
Kris Traughber23-Apr-10 5:22 
GeneralRe: Beginner Question: Distributing Data Driven Applications Pin
dan!sh 23-Apr-10 5:29
professional dan!sh 23-Apr-10 5:29 
AnswerRe: Beginner Question: Distributing Data Driven Applications Pin
Sandesh M Patil23-Apr-10 5:52
Sandesh M Patil23-Apr-10 5:52 
GeneralRe: Beginner Question: Distributing Data Driven Applications Pin
Kris Traughber23-Apr-10 6:20
Kris Traughber23-Apr-10 6:20 
GeneralRe: Beginner Question: Distributing Data Driven Applications Pin
Sandesh M Patil23-Apr-10 6:54
Sandesh M Patil23-Apr-10 6:54 
AnswerRe: Beginner Question: Distributing Data Driven Applications Pin
kevinnicol23-Apr-10 6:28
kevinnicol23-Apr-10 6:28 
GeneralRe: Beginner Question: Distributing Data Driven Applications Pin
Kris Traughber23-Apr-10 6:47
Kris Traughber23-Apr-10 6:47 
AnswerRe: Beginner Question: Distributing Data Driven Applications Pin
AspDotNetDev23-Apr-10 6:56
protectorAspDotNetDev23-Apr-10 6:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.