jeudi 1 septembre 2016

Check Checkbox from 1 Group to Another

Good Morning I want to ask something that is related in checkboxes I have to groups of checkboxes and it looks like this

enter image description here

My question is How can i check the checkbox Purchase Requisition whenever i check any checkbox in Group Purchase Requisition and if all of them are uncheck then checkbox Purchase Requisition is unchecked.

I have this code and I put this code on all of the checkbox inside Groupbox Purchase Requisition

  Sub check_Purchase_Req()
        Dim oCtl As Control
        Dim iX As Integer

        For Each oCtl In GroupBox3.Controls
            If TypeName(oCtl) = "CheckBox" And oCtl.Enabled = True Then iX = iX + 1

            If iX > 0 Then
                CheckBox1.Checked = True

            ElseIf CheckBox19.Checked = False And CheckBox20.Checked = False And CheckBox21.Checked = False And CheckBox22.Checked = False And CheckBox23.Checked = False Then

                CheckBox1.Checked = False
                Exit For
            End If
        Next
    End Sub

but this code doesnt meet what I need

Any help is appreciated TYSM




How to check which checkboxes are checked or not? [duplicate]

This question already has an answer here:

I have multiple checkboxes with same class name . I want to check which checkboxes are checked in jquery?

How can I do this?




angular2 group of checkboxes with required attribute

i want to create a template-driven form in Angular2 (RC5), that will include a group of check-boxes, bounded to specific attributes of an object. Right now, i have such group, bounded to the corresponding array like:

<div class="checkbox" *ngFor="let prop of properties">
  <label>
    <input type="checkbox" name="option" id="option [(ngModel)]="prop.state"/> 
    
  </label>
</div>

Although this is pretty straightforward, i cannot figure out how to add a required attribute to this group of check-boxes. What i mean by that, is that i need to force user to select AT LEAST one of the group check-boxes, otherwise form validation will fail.

Any ideas?




How to save checkBox state using SharedPreferences in android

I have an AlertDialog CheckBox. I want to save checkbox state in sharedPreferences when I check, and again when app restart and I open the Dialog checkbox, state auto check which I save. How to make this please help me.

Here is my code:

    set_repeat_days = (LinearLayout)findViewById(R.id.repeat_days);
    set_repeat_days.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            AlertDialog.Builder builder = new AlertDialog.Builder(SettingsActivity.this);

            String[] days = new String[]{"Monday", "Thursday", "Wednesday", "Tuesday", "Friday", "Saturday", "Sunday"};
            final boolean[] checkedDays = new boolean[]{false, true, true, true, true, true, true};
            final List<String> daysList = Arrays.asList(days);

            builder.setMultiChoiceItems(days, checkedDays, new DialogInterface.OnMultiChoiceClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int which, boolean isChecked) {
                    // Update the current focused item's checked status
                    checkedDays[which] = isChecked;
                    // Get the current focused item
                    String currentItem = daysList.get(which);

                    Toast.makeText(getApplicationContext(),
                            currentItem + " " + isChecked, Toast.LENGTH_SHORT).show();
                }
            });
            // Specify the dialog is not cancelable
            builder.setCancelable(false);
            builder.setTitle("Repeat");

            // Set the positive/yes button click listener
            builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    repeat_list = (TextView)findViewById(R.id.repeat_list);
                    for (int i = 0; i<checkedDays.length; i++){
                        boolean checked = checkedDays[i];
                        if (checked){
                            String day = (daysList.get(i) + ", ");
                            repeat_list.setText(day);
                        }
                    }

                }
            });
            // Set the neutral/cancel button click listener
            builder.setNeutralButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                }
            });
            AlertDialog dialog = builder.create();
            dialog.show();
        }
    });




Qtreeview checkbox has empty focus

Why does my qtreeview, using pyside, have this little small empty boxed area that the user can click and get a dotted focus box around? How can i remove it. I only want a simple checkbox in the first column.

enter image description here

code

import sys
from PySide import QtGui, QtCore

class SortModel(QtGui.QSortFilterProxyModel):

    def __init__(self, *args, **kwargs):
        super(SortModel, self).__init__(*args, **kwargs)

    def lessThan(self, left, right):
        leftData = self.sourceModel().data(left)
        rightData = self.sourceModel().data(right)

        if leftData:
            leftData = leftData.lower()
        if rightData:
            rightData = rightData.lower()

        print('L:', leftData, 'R:', rightData)
        return leftData < rightData


class Browser(QtGui.QDialog):
    def __init__(self, parent=None):
        super(Browser, self).__init__(parent)

        self.initUI()

    def initUI(self):
        self.resize(200, 300)
        self.setWindowTitle('Assets')
        self.setModal(True)

        self.results = ""

        self.uiItems = QtGui.QTreeView()
        self.uiItems.setAlternatingRowColors(True)
        self.uiItems.setSortingEnabled(True)
        self.uiItems.sortByColumn(1, QtCore.Qt.AscendingOrder)
        self.uiItems.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
        self.uiItems.header().setResizeMode(QtGui.QHeaderView.ResizeToContents)
        self.uiItems.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
        self.uiItems.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
        self._model = self.create_model(self)
        self._spmodel = SortModel(self)
        self._spmodel.setSourceModel(self._model)
        self._spmodel.setDynamicSortFilter(True)
        self.uiItems.setModel(self._spmodel)

        grid = QtGui.QGridLayout()
        grid.setContentsMargins(0, 0, 0, 0)
        grid.addWidget(self.uiItems, 0, 0)
        self.setLayout(grid)

        self.setLayout(grid)
        self.update_asset_model()
        self.uiItems.doubleClicked.connect(self.doubleClickedItem)
        self.show()

    def doubleClickedItem(self, idx):
        if not idx.isValid():
            return
        print idx.parent(), idx.parent().isValid()
        model = idx.model()
        print model.index(idx.row(), 0, parent=idx.parent()).data()

    def create_model(self, parent):
        model = QtGui.QStandardItemModel()
        model.setHorizontalHeaderLabels([])
        return model

    def add_row_item(self, model, name, _type):
        model.insertRow(0)
        model.setData(model.index(0, 0), '')
        model.setData(model.index(0, 0), QtCore.Qt.Checked,
            role = QtCore.Qt.CheckStateRole
        )
        model.setData(model.index(0, 1), name)
        model.setData(model.index(0, 2), _type)
        model.setData(model.index(0, 2),
            QtGui.QBrush(QtGui.QColor(200, 140, 70, 255)),
            role=QtCore.Qt.ForegroundRole
        )

    def update_asset_model(self):
        model = self.uiItems.model().sourceModel()
        model.clear()
        model.setHorizontalHeaderLabels(['', 'Name', "Output"])

        items = {
            'Doug' : "C:/fire/cache_.jpeg",
            'Mike' : "C:/smoke/cache_.tga",
            'Kevin' : "C:/water/cache_.tif",
            'Curt' : "C:/steam/cache_.jpg",
            'Corey' : "C:/blood/cache_.png"
        }

        for n in items.keys():
            self.add_row_item(model, n, items[n])

    def showEvent(self, event):
        geom = self.frameGeometry()
        geom.moveCenter(QtGui.QCursor.pos())
        self.setGeometry(geom)
        super(Browser, self).showEvent(event)

    def keyPressEvent(self, event):
        if event.key() == QtCore.Qt.Key_Escape:
            # self.hide()
            self.close()
            event.accept()
        else:
            super(Browser, self).keyPressEvent(event)


def main():
    app = QtGui.QApplication(sys.argv)
    ex = Browser()
    sys.exit(app.exec_())


if __name__ == '__main__':
    main()
enter code here




Validate status checkbox vb asp net codebehind

hi i need to implement the following rule as validate that there is an active checkbox least in the gridview

and you can not disable

and if there is an active checkbox minimum (1 true) in the gridview can activate others that are inactive (0 false)

sorry for my english :)

select COUNT(*) enabled from checkbox where checkbox.Enabled = 1

 Dim total As New checkboxdal
 Dim totalcheckboxActive = total.totalCheckboxEnabled(UC)

If totalcheckboxActive > 1 Then

            dt.Enabled = chkActive.Checked

            Dim Data = ad.updateAspects(UC, dt)

            SetResult(String.Format("update '{0}' successful", dt.Enabled ))
        Else
          Response.Write("<script>alert('You must have at least one checkbox active.');</script>")
            End If

        End If




how to use checkbox checked on html-el:checkbox in struts

I want to use checked attribute on html-el:checkbox in struts. But there is no attribute for that. When i use checked="checked" the page is blowing up..Is there any alternative to check whether checkbox is checked,