473,729 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

There never enough controls... I need a multi column, multi checkbox listview

Hi all,

I don't want to use the datagrid if I don't have to. Is there a way to
setup a ListBox to have more than one checkbox column?

I need something like this
| Include || Set as Default || Other columns... |
[X] [ ] asdasdasd
[X] [X] digity-digity!
Quick scan on CodeProject came up with a not-so-pretty MFC control, but
obviously... I would like a c# one.

Thanks for any tips!
Jul 11 '06 #1
4 5592
I would have thought datagrid ideal for this since you can customise
the type and the control for each column.

But otherwise I guess you could write your own control to do it as
well.

Jul 11 '06 #2
You could write your own Control to do this in a couple of hours. Start by
inheriting UserControl.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

Big thicks are made up of lots of little thins.
"Steve" <sk**@skle.comw rote in message
news:%2******** *******@TK2MSFT NGP05.phx.gbl.. .
Hi all,

I don't want to use the datagrid if I don't have to. Is there a way to
setup a ListBox to have more than one checkbox column?

I need something like this
| Include || Set as Default || Other columns... |
[X] [ ] asdasdasd
[X] [X] digity-digity!
Quick scan on CodeProject came up with a not-so-pretty MFC control, but
obviously... I would like a c# one.

Thanks for any tips!

Jul 11 '06 #3
The native ListView (i.e. the Win32 one) supports sub item images so it
should be pretty simple to add that support by inheriting ListView and doing
some P/Invoke stuff. Check out the LVS_EX_SUBITEMI MAGES style. Once you have
the images in place you just need to track the check state. The following
class has support for sub item images:

using System;
using System.Runtime. InteropServices ;
public class ListViewEx : System.Windows. Forms.ListView
{
private const int LVIF_IMAGE = 0x2;
private const int LVS_EX_SUBITEMI MAGES = 0x2;
private const int LVM_FIRST = 0x1000;
private const int LVM_GETITEMA = LVM_FIRST + 5;
private const int LVM_GETITEMW = LVM_FIRST + 75;
private static readonly int LVM_GETITEM = (Marshal.System DefaultCharSize
== 1) ? LVM_GETITEMA : LVM_GETITEMW;
private const int LVM_SETITEMA = LVM_FIRST + 6;
private const int LVM_SETITEMW = LVM_FIRST + 76;
private static readonly int LVM_SETITEM = (Marshal.System DefaultCharSize
== 1) ? LVM_SETITEMA : LVM_SETITEMW;
private const int LVM_SETEXTENDED LISTVIEWSTYLE = LVM_FIRST + 54;

[DllImport("User 32.dll", CharSet = CharSet.Auto)]
private static extern int SendMessage(Int Ptr hwnd, int msg, IntPtr
wParam, ref LVITEM lParam);
[DllImport("User 32.dll", CharSet=CharSet .Auto)]
private static extern int SendMessage(Int Ptr hwnd, int msg, IntPtr
wParam, IntPtr lParam);

[StructLayout(La youtKind.Sequen tial, CharSet=CharSet .Auto)]
private struct LVITEM
{
public int mask;
public int iItem;
public int subItem;
public int state;
public int stateMask ;
[MarshalAs(Unman agedType.LPTStr )]
public string lpszText;
public int cchTextMax;
public int iImage;
public IntPtr lParam;
public int iIndent;
}

private bool ListView_SetIte m(IntPtr hwnd, ref LVITEM lvi)
{
int result = SendMessage(hwn d, LVM_SETITEM, IntPtr.Zero, ref lvi);
return (result == 0) ? false : true;
}

private bool ListView_GetIte m(IntPtr hwnd, ref LVITEM lvi)
{
int result = SendMessage(hwn d, LVM_GETITEM, IntPtr.Zero, ref lvi);
return (result == 0) ? false : true;
}

private void ListView_SetExt endedListViewSt yleEx(IntPtr hwnd, int mask,
int style)
{
SendMessage(hwn d, LVM_SETEXTENDED LISTVIEWSTYLE, new IntPtr(mask),
new IntPtr(style));
}

private void ListView_SetSub ItemImageIndex( IntPtr hwnd, int index, int
subItemIndex, int imageIndex)
{
LVITEM lvi = new LVITEM();
lvi.iItem = index;
lvi.subItem = subItemIndex;
lvi.iImage = imageIndex;
lvi.mask = LVIF_IMAGE;
ListView_SetIte m(hwnd, ref lvi);
}

private int ListView_GetSub ItemImageIndex( IntPtr hwnd, int index, int
subItemIndex)
{
LVITEM lvi = new LVITEM();
lvi.iItem = index;
lvi.subItem = subItemIndex;
lvi.mask = LVIF_IMAGE;
if (ListView_GetIt em(hwnd, ref lvi))
return lvi.iImage;
else
return -1;
}

protected override void OnCreateControl ()
{
base.OnCreateCo ntrol();
ListView_SetExt endedListViewSt yleEx(this.Hand le,
LVS_EX_SUBITEMI MAGES, LVS_EX_SUBITEMI MAGES);
}

public void SetSubItemImage Index(int index, int subItemIndex, int
imageIndex)
{
ListView_SetSub ItemImageIndex( this.Handle, index, subItemIndex,
imageIndex);
}

public int GetSubItemImage Index(int index, int subItemIndex)
{
return ListView_GetSub ItemImageIndex( this.Handle, index,
subItemIndex);
}
}

/claes

"Steve" <sk**@skle.comw rote in message
news:%2******** *******@TK2MSFT NGP05.phx.gbl.. .
Hi all,

I don't want to use the datagrid if I don't have to. Is there a way to
setup a ListBox to have more than one checkbox column?

I need something like this
| Include || Set as Default || Other columns... |
[X] [ ] asdasdasd
[X] [X] digity-digity!
Quick scan on CodeProject came up with a not-so-pretty MFC control, but
obviously... I would like a c# one.

Thanks for any tips!

Jul 11 '06 #4
Hi Steve,

If licensing money isn't an problem, consider going for a 3rd party
grid component. In our company we make extensive use of the VSFlexGrid
control by ComponentOne. It is fast, easy to program to and feature
rich and will handle your requirements quite easily.

Regards,
Pieter
Steve wrote:
Hi all,

I don't want to use the datagrid if I don't have to. Is there a way to
setup a ListBox to have more than one checkbox column?

I need something like this
| Include || Set as Default || Other columns... |
[X] [ ] asdasdasd
[X] [X] digity-digity!
Quick scan on CodeProject came up with a not-so-pretty MFC control, but
obviously... I would like a c# one.

Thanks for any tips!
Jul 11 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
23359
by: John R. | last post by:
I want to have a listbox that shows a checkbox and a textbox. I created a user control that has a checkbox and a textbox in it and have been trying to add it to a listbox but I can't get it to show up for each item I add to the listbox. foreach (Column column in columns) { ColumnsListBox.Items.Add(column.Name); ColumnsListBox.Controls.Add(new ColumnListControl(true, column.Name,
2
2035
by: Colin McGuigan | last post by:
This is a translation of an ASP page to ASP.Net. First, the background: The goal is to have a grid of different settings for the application -- think something along the lines of the Property Page for a control. You have two columns -- the first column is a simple caption, and the second column can be one of a number of controls (textbox, checkbox, dropdownlist, etc) for each row. So row #1 might have a textbox in the second column,...
0
1518
by: bill yeager | last post by:
I have a datalist displaying parent information and a datagrid presenting child information. The data is being rendered just fine. The datagrid has template columns on it that I cannot gain access to in my Itemcommand event of the datalist. When I press a button on the datalist, that brings me into the Itemcommand event. I have access to the datagrid control, but not any column controls on the datagrid. For instance, my first column is...
2
12357
by: Michael | last post by:
Need some help trying to read values from web controls - specifically *finding* the controls (like a drop down list) - that are added dynamically added within an asp:panel control. The page contains multiple panels within the form. The panels appear at different times - for our argument, let's say panel 1 appears first, users clicks a submit button and then panel 1 disappears and panel 2 appears, etc. When clicks on the submit button...
3
2343
by: Ankit Aneja | last post by:
I have a strange situation and I have no idea how to solve this. Its a Recruitment Search Page,in the Admin Page, for every button click event the Admin Person has to create a checkbox on the users page. So whenever the Admin person comes to know about the new category in the market he will be adding as different Sub-Categories for example ABAP, BDC etc..etc.. on every click event as Checkboxes. And these controls(checkboxes) should remain...
6
1937
by: Josef Brunner | last post by:
Hi, I have a problem using two ListView controls on one and the same form: Problem: The second ListView is never focused. No matter where I "click" non of the items within the ListView is focused. This is only the matter for the secondly added ListView!!! The first one works perfectly!!
2
2793
by: mongphong28 | last post by:
Hi, In VB6 I could create the appearance of a checkbox column in a listview by toggling an image when the user clicked in the appropriate cell. This same kind of column can be seen in MS Access and is different to the built in Checkboxes property of a listview which puts checkboxes at the left of the item. Does anyone know how to do this in VB.Net?
9
1662
by: active | last post by:
I need a control that displays a grid of rectangles. That is, like a brick wall except the rectangles are lined up. In VB6 I used such a control (may have been called FlexGrid but I'm not sure.) I did see the DataGrid control but that seems oriented to DB usage. It's probably much more complex than what I need, but I'm not sure about that!
0
2310
by: bharathreddy | last post by:
Hi All, I am using a listview control in my usercontrol so that it can be used in more than one form. This user control has one column extraw, so i want to make it invisible depending on the form it is being used. I am using table in the listview control for formating purpose. In this table I want to hide a column. Is it posible to hide the column?. I am facing the problem because I cant catch the row its showing null values. ...
0
8761
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9281
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8148
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.