Home All Groups Group Topic Archive Search About

disabling checkbox in checkedlistbox

Author
19 Jul 2006 4:03 PM
ameen.abdullah
Hi Guys,

I have a checked list box on my form.. the purpose of this checkbox is
to indicate that the option is enabled or disabled.. I just want to ask
if there is a way to disable these check boxes from being checked or
unchecked.. i want them to always show their default value which i have
fetched from a xml file.. and also i dont want the checked list box to
be disabled, as i want the user to select any item but not change the
checked state.

Thanks in advance guys..

Author
19 Jul 2006 4:29 PM
Izzy
Are you familiar with Infragistics controls or do you use them?

If so, this is how I would do it:

I would use thier Ultra DataGrid and add 2 columns to it. One is the
description column and the other is the boolean column. Then load your
data and disable editing and set the CellClickActions property of the
grid to RowSelect.

This way they can view and select but not edit.

If you use Microsoft's grid, you can try this method but no guarantees.



ameen.abdul***@gmail.com wrote:
Show quoteHide quote
> Hi Guys,
>
> I have a checked list box on my form.. the purpose of this checkbox is
> to indicate that the option is enabled or disabled.. I just want to ask
> if there is a way to disable these check boxes from being checked or
> unchecked.. i want them to always show their default value which i have
> fetched from a xml file.. and also i dont want the checked list box to
> be disabled, as i want the user to select any item but not change the
> checked state.
>
> Thanks in advance guys..
Author
19 Jul 2006 4:34 PM
ameen.abdullah
I m using microsoft's checkedlistbox control.. i has builtin checkbox
with every item and i jus wan to disable that checkbox..

cant use datagrids.. ill have to change the control over more then 10
places :(

Izzy wrote:
Show quoteHide quote
> Are you familiar with Infragistics controls or do you use them?
>
> If so, this is how I would do it:
>
> I would use thier Ultra DataGrid and add 2 columns to it. One is the
> description column and the other is the boolean column. Then load your
> data and disable editing and set the CellClickActions property of the
> grid to RowSelect.
>
> This way they can view and select but not edit.
>
> If you use Microsoft's grid, you can try this method but no guarantees.
>
>
>
> ameen.abdul***@gmail.com wrote:
> > Hi Guys,
> >
> > I have a checked list box on my form.. the purpose of this checkbox is
> > to indicate that the option is enabled or disabled.. I just want to ask
> > if there is a way to disable these check boxes from being checked or
> > unchecked.. i want them to always show their default value which i have
> > fetched from a xml file.. and also i dont want the checked list box to
> > be disabled, as i want the user to select any item but not change the
> > checked state.
> >
> > Thanks in advance guys..
Author
19 Jul 2006 4:34 PM
ameen.abdullah
I m using microsoft's checkedlistbox control.. it has builtin checkbox
with every item and i jus wan to disable that checkbox..

cant use datagrids.. ill have to change the control over more then 10
places :(

Izzy wrote:
Show quoteHide quote
> Are you familiar with Infragistics controls or do you use them?
>
> If so, this is how I would do it:
>
> I would use thier Ultra DataGrid and add 2 columns to it. One is the
> description column and the other is the boolean column. Then load your
> data and disable editing and set the CellClickActions property of the
> grid to RowSelect.
>
> This way they can view and select but not edit.
>
> If you use Microsoft's grid, you can try this method but no guarantees.
>
>
>
> ameen.abdul***@gmail.com wrote:
> > Hi Guys,
> >
> > I have a checked list box on my form.. the purpose of this checkbox is
> > to indicate that the option is enabled or disabled.. I just want to ask
> > if there is a way to disable these check boxes from being checked or
> > unchecked.. i want them to always show their default value which i have
> > fetched from a xml file.. and also i dont want the checked list box to
> > be disabled, as i want the user to select any item but not change the
> > checked state.
> >
> > Thanks in advance guys..
Author
19 Jul 2006 6:49 PM
Izzy
That can be accomplished like this:

Private Sub CheckedListBox1_ItemCheck(ByVal sender As Object, ByVal e
As System.Windows.Forms.ItemCheckEventArgs) Handles
CheckedListBox1.ItemCheck
        e.NewValue = e.CurrentValue
    End Sub

In the "ItemCheck" Property of the check list box you just reset the
e.NewValue to the e.CurrentValue.

Hope this helps!


ameen.abdul***@gmail.com wrote:
Show quoteHide quote
> I m using microsoft's checkedlistbox control.. it has builtin checkbox
> with every item and i jus wan to disable that checkbox..
>
> cant use datagrids.. ill have to change the control over more then 10
> places :(
>
> Izzy wrote:
> > Are you familiar with Infragistics controls or do you use them?
> >
> > If so, this is how I would do it:
> >
> > I would use thier Ultra DataGrid and add 2 columns to it. One is the
> > description column and the other is the boolean column. Then load your
> > data and disable editing and set the CellClickActions property of the
> > grid to RowSelect.
> >
> > This way they can view and select but not edit.
> >
> > If you use Microsoft's grid, you can try this method but no guarantees.
> >
> >
> >
> > ameen.abdul***@gmail.com wrote:
> > > Hi Guys,
> > >
> > > I have a checked list box on my form.. the purpose of this checkbox is
> > > to indicate that the option is enabled or disabled.. I just want to ask
> > > if there is a way to disable these check boxes from being checked or
> > > unchecked.. i want them to always show their default value which i have
> > > fetched from a xml file.. and also i dont want the checked list box to
> > > be disabled, as i want the user to select any item but not change the
> > > checked state.
> > >
> > > Thanks in advance guys..
Author
19 Jul 2006 7:05 PM
Izzy
Oops...I should test before I post, the e.NewValue = e.OldValue will
work but it loads the checked list box will everything unchecked. So to
work around that, do this:

Public Class Form1

    Private FinishedLoading As Boolean = False

    Private Sub CheckedListBox1_ItemCheck(ByVal sender As Object, ByVal
e As System.Windows.Forms.ItemCheckEventArgs) Handles
CheckedListBox1.ItemCheck
'Only perform if the form is finished loading.
If FinishedLoading Then e.NewValue = e.CurrentValue
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
        'Load data
        CheckedListBox1.Items.Add("test1", True)
        CheckedListBox1.Items.Add("test2", True)
        CheckedListBox1.Items.Add("test3", False)
        CheckedListBox1.Items.Add("test4", False)
        CheckedListBox1.Items.Add("test5", True)
        CheckedListBox1.Items.Add("test6", True)
        CheckedListBox1.Items.Add("test7", False)

        'Throw finished loading flag
        FinishedLoading = True
    End Sub
End Class


All this seems like such a hack to me, I'd just use a datagrid, but
since that's not an option......the above will work.


Izzy wrote:
Show quoteHide quote
> That can be accomplished like this:
>
> Private Sub CheckedListBox1_ItemCheck(ByVal sender As Object, ByVal e
> As System.Windows.Forms.ItemCheckEventArgs) Handles
> CheckedListBox1.ItemCheck
>         e.NewValue = e.CurrentValue
>     End Sub
>
> In the "ItemCheck" Property of the check list box you just reset the
> e.NewValue to the e.CurrentValue.
>
> Hope this helps!
>
>
> ameen.abdul***@gmail.com wrote:
> > I m using microsoft's checkedlistbox control.. it has builtin checkbox
> > with every item and i jus wan to disable that checkbox..
> >
> > cant use datagrids.. ill have to change the control over more then 10
> > places :(
> >
> > Izzy wrote:
> > > Are you familiar with Infragistics controls or do you use them?
> > >
> > > If so, this is how I would do it:
> > >
> > > I would use thier Ultra DataGrid and add 2 columns to it. One is the
> > > description column and the other is the boolean column. Then load your
> > > data and disable editing and set the CellClickActions property of the
> > > grid to RowSelect.
> > >
> > > This way they can view and select but not edit.
> > >
> > > If you use Microsoft's grid, you can try this method but no guarantees.
> > >
> > >
> > >
> > > ameen.abdul***@gmail.com wrote:
> > > > Hi Guys,
> > > >
> > > > I have a checked list box on my form.. the purpose of this checkbox is
> > > > to indicate that the option is enabled or disabled.. I just want to ask
> > > > if there is a way to disable these check boxes from being checked or
> > > > unchecked.. i want them to always show their default value which i have
> > > > fetched from a xml file.. and also i dont want the checked list box to
> > > > be disabled, as i want the user to select any item but not change the
> > > > checked state.
> > > >
> > > > Thanks in advance guys..
Author
20 Jul 2006 10:42 AM
ameen.abdullah
awesome man.. i worked perfectly :) thanks alot

Izzy wrote:
Show quoteHide quote
> Oops...I should test before I post, the e.NewValue = e.OldValue will
> work but it loads the checked list box will everything unchecked. So to
> work around that, do this:
>
> Public Class Form1
>
>     Private FinishedLoading As Boolean = False
>
>     Private Sub CheckedListBox1_ItemCheck(ByVal sender As Object, ByVal
> e As System.Windows.Forms.ItemCheckEventArgs) Handles
> CheckedListBox1.ItemCheck
> 'Only perform if the form is finished loading.
> If FinishedLoading Then e.NewValue = e.CurrentValue
>     End Sub
>
>     Private Sub Form1_Load(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Me.Load
>         'Load data
>         CheckedListBox1.Items.Add("test1", True)
>         CheckedListBox1.Items.Add("test2", True)
>         CheckedListBox1.Items.Add("test3", False)
>         CheckedListBox1.Items.Add("test4", False)
>         CheckedListBox1.Items.Add("test5", True)
>         CheckedListBox1.Items.Add("test6", True)
>         CheckedListBox1.Items.Add("test7", False)
>
>         'Throw finished loading flag
>         FinishedLoading = True
>     End Sub
> End Class
>
>
> All this seems like such a hack to me, I'd just use a datagrid, but
> since that's not an option......the above will work.
>
>
> Izzy wrote:
> > That can be accomplished like this:
> >
> > Private Sub CheckedListBox1_ItemCheck(ByVal sender As Object, ByVal e
> > As System.Windows.Forms.ItemCheckEventArgs) Handles
> > CheckedListBox1.ItemCheck
> >         e.NewValue = e.CurrentValue
> >     End Sub
> >
> > In the "ItemCheck" Property of the check list box you just reset the
> > e.NewValue to the e.CurrentValue.
> >
> > Hope this helps!
> >
> >
> > ameen.abdul***@gmail.com wrote:
> > > I m using microsoft's checkedlistbox control.. it has builtin checkbox
> > > with every item and i jus wan to disable that checkbox..
> > >
> > > cant use datagrids.. ill have to change the control over more then 10
> > > places :(
> > >
> > > Izzy wrote:
> > > > Are you familiar with Infragistics controls or do you use them?
> > > >
> > > > If so, this is how I would do it:
> > > >
> > > > I would use thier Ultra DataGrid and add 2 columns to it. One is the
> > > > description column and the other is the boolean column. Then load your
> > > > data and disable editing and set the CellClickActions property of the
> > > > grid to RowSelect.
> > > >
> > > > This way they can view and select but not edit.
> > > >
> > > > If you use Microsoft's grid, you can try this method but no guarantees.
> > > >
> > > >
> > > >
> > > > ameen.abdul***@gmail.com wrote:
> > > > > Hi Guys,
> > > > >
> > > > > I have a checked list box on my form.. the purpose of this checkbox is
> > > > > to indicate that the option is enabled or disabled.. I just want to ask
> > > > > if there is a way to disable these check boxes from being checked or
> > > > > unchecked.. i want them to always show their default value which i have
> > > > > fetched from a xml file.. and also i dont want the checked list box to
> > > > > be disabled, as i want the user to select any item but not change the
> > > > > checked state.
> > > > >
> > > > > Thanks in advance guys..
Author
20 Jul 2006 2:35 AM
Cor Ligthert [MVP]
Ameen,

Is it not easier for your problem to use a listbox and put in that all the
possibilities while what is not possible is not in that listbox. (You can
even make one where you put something with a string concatenation in)

v Possible
- Not possible
v As well possible

The way you describe it, makes that you have if you have solved this problem
have to find how to find the checkbox that is selected while it is not
selected.

Just my thought,

Cor

<ameen.abdul***@gmail.com> schreef in bericht
Show quoteHide quote
news:1153325002.517913.127390@i3g2000cwc.googlegroups.com...
> Hi Guys,
>
> I have a checked list box on my form.. the purpose of this checkbox is
> to indicate that the option is enabled or disabled.. I just want to ask
> if there is a way to disable these check boxes from being checked or
> unchecked.. i want them to always show their default value which i have
> fetched from a xml file.. and also i dont want the checked list box to
> be disabled, as i want the user to select any item but not change the
> checked state.
>
> Thanks in advance guys..
>
Author
20 Jul 2006 10:44 AM
ameen.abdullah
hey Cor, very goood idea :) thanks for the reply..

Cor Ligthert [MVP] wrote:
Show quoteHide quote
> Ameen,
>
> Is it not easier for your problem to use a listbox and put in that all the
> possibilities while what is not possible is not in that listbox. (You can
> even make one where you put something with a string concatenation in)
>
> v Possible
> - Not possible
> v As well possible
>
> The way you describe it, makes that you have if you have solved this problem
> have to find how to find the checkbox that is selected while it is not
> selected.
>
> Just my thought,
>
> Cor
>
> <ameen.abdul***@gmail.com> schreef in bericht
> news:1153325002.517913.127390@i3g2000cwc.googlegroups.com...
> > Hi Guys,
> >
> > I have a checked list box on my form.. the purpose of this checkbox is
> > to indicate that the option is enabled or disabled.. I just want to ask
> > if there is a way to disable these check boxes from being checked or
> > unchecked.. i want them to always show their default value which i have
> > fetched from a xml file.. and also i dont want the checked list box to
> > be disabled, as i want the user to select any item but not change the
> > checked state.
> >
> > Thanks in advance guys..
> >