dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 12 of 12

Thread: Listview multicolumn uneditable checkbox

  1. #1
    Join Date
    Apr 2005
    Posts
    32

    Listview multicolumn uneditable checkbox

    Hi Guys

    I am having harrowing time in adjusting listview for my requirements.
    I need to display 5 columns in listview. first and fourth columns will be represented by only checkboxes. These will be checked
    or unchecked depending up on values from a table. These should not be editable during run time.

    Rows will depend up on a global variable glo.index.

    In 2nd column, glo.index will values go in.

    In 3rd column, the string will be taken from a table and displayed.
    5th column will have a const. string as its value.

    For i = glo.index+ 1 To ubound(array)

    With listview

    .ListItem.Add i
    .ListItems.item(i).Checked = False

    .ListItems.item(i).SubItems(1) = i




    .ListItems.ListSubItems(2) = "data from table1"


    .ListItems.ListSubItems(3)=false ' here check box should be added in column 4 but could not


    .ListItems.ListSubItems(4) = "Multiple Choice" 'a string cont value


    End With
    Next




    If I change anything to get checkboxes in listsubitems(3) I get medley of runtime and compile errors. Please help me.
    In short I have these troubles:

    1) The checkboxes which are coming in first column are editable in runtime, I want them to be uneditable.( labeledit=lvwmanual is not working for checkbox)
    2) In more than 1 column, checkbox must come in uneditable mode.
    3) for above code, there appears 6 columns last one empty. I want to make it disappear. Also I want to change the appearance of listview depending up on number
    of rows. i.e size should be same for 5 or 6 rows and 50 rows. If there are 50, contents must be scrolled.

    p.s: Marco, Phil please help me
    Last edited by maheeru; 07-30-2005 at 03:30 AM.

  2. #2
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    am I the Marco you referring to?
    The ListBox allows check boxes only in the first column, and I do not know if it can be disabled it.
    For that reason, instead of using the ListBox I use a FlexGrid (if you do not display the grid lines it looks very much alike the ListView). I created two icons, CheckBoxOn and CheckBoxOff (copying the standard checkbox) and I display them in the column/cell I want to using the CellPicture property. In the MouseDown event, I check if the mouse in over the region of the cell where the icon is, and in that case I toggle the icon.
    It looks like a lot of work, but in fact it is quite easy, it is an all-vb solution, does not require API's or third party components (the flexgrid comes with vb)
    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  3. #3
    Join Date
    Apr 2005
    Posts
    32
    Yeah thanks Marco.

    But I need a little bit more of info. How to make flexgrid look as same like listview reportmode, exactly with gridlines.

    when a row is clicked, I get some value from item so that appropriate record from database could be displayed. Is that possible with flexgrid. I m new to flexgrid control.

  4. #4
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    the flex grid is really very... flexible.

    I suggest you to start a simple exe with a grid in it, and play with their properties until the grid has the look and fill you need. To start with, you can set a fixed number of rows and columns (fixedrows and fixedcols, I beleive), these will not scroll, thus can be used as 'headers'. Setting fixrows=1 and fixcols=0 it will looks like a list view. Then look at the properties starting with 'grid', that change the aspect of the gird lines. And so on, there are so many properties that you have to experiment by yourself.

    Regarding attaching data to the grid, there are two properties (RowData and ColData) that can store a Long for each row and column. If you need more than a Long, then you need an extra array or collection, to store adjacent data. This is more painful, because there are two lists (the gird and the array) that need to be kept in sync. Usually I store the RowData as a the key in a private collection, where I can keep whatever I want. Even for this, you need to find what is best for you. Someone prefer to store data in a hidden column (that is, a column with width = 0)

    Good luck, and let me know.
    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  5. #5
    Join Date
    Apr 2005
    Posts
    32
    In my last reply I forgot to add my following doubts. Please let me know the information

    whether flexgrid control(it refers to ms-flexgrid 6(sp3) or ms hierarchical flexgrid 6(oledb)) could be fine tuned for say if end user keeps his arrow over any row and it must be highlighted, if he clicks it the value from second column of that
    row should be retrieved and corresponding record should be displayed in another textbox which will superimpose on listview/flexgrid.

    If I skipped the mousedown event you ve specified, is it possible for me to prevent the user from toggling the checkboxes. For me the checkbox column must not be changed by user. It d only be changed by code.

    P.s:THanks for your information I will revert after making a try.

  6. #6
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    As I said in my first reply, the flexGrid (I use the standard on, not the hierarchical) does not have check boxes, that can be simulated with icons. Thus is up to the code to paint the right icon (on/off) so you are rigth that you can just skip the mousedown event. What is nice is that you can put any image you want in any cell... with the right justification.

    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  7. #7
    Join Date
    Apr 2005
    Posts
    32
    Marco thanks for information.

    If I want to save some of reports (to be displayed later), which are displayed in flexgrid(moulded like listview report mode) is that possible to save those reports and retrieve on demand such that saved reports look same on flexgrid similar to when they were saved.

  8. #8
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    please start another thread, it is more likely that someone with report knowledge will read it and answer
    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  9. #9
    Join Date
    Apr 2005
    Posts
    32
    Hi Marco, your advice to switch over to flexgrid was worthy. It made my work much easy.
    Now I ve following doubts in that.
    1)Is that possible in msflexgrid where whole row is highlighted(For me leaving first field all other fields are highlighted, how to include first field I dont know).
    2)Is that possible to use .selRow property to include a whole row to be displayed when its displayed initially.
    3)on mousemove,if the row must be highlighted, is it necessary to capture mousemove event or any property
    4) I tried by copying and pasting checkbox in ms-paint for .ico files but they dont fit in to checkbox field of flexgrid in .cellpicture property. Please check my zip file and tell me what is the problem with .ico files as they have large size than other system .ico files and one picture itself covers entire flexgrid.
    Attached Files Attached Files

  10. #10
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    Regarding you first questions, you just have to esperiment yourself. As you saw, there are a lot of properties you can play with...
    I think the flexGrid has a mouseMove event. Grab that, and use MouseCol and MouseRow to know in which cell the mouse is in (and they are different from Row and Col)
    You ico files are all wrong they are just huge bitmaps. you must use DevStudio or .NET to create a icon file.
    Finally, there is a little bug in the flexgrid. If you load a 16x16 icon, the grid automatically expands it to 32x32... so what I do is to create ONLY a 32x32 icon, and put the image in the top 16x16 pixels...
    Now, the good think of the icons is that they have a 'transparent' color. But if you can go without it, just create a 16x16 bitmap using Paint
    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  11. #11
    Join Date
    Apr 2005
    Posts
    32
    Hi
    I tried with 16*16 bit in ms-paint still that .ico file wont fit within a cell rather its a bit big. I dont ve .net or devstudio. what's the easy way to create .ico files.

    I tried the piece that

    flexgrid.selrow =1
    when first the report is showed. at that time in 4th column 4 rows are highlighted. But what I want is to highlight the first row after header to be highlighted.

    I dont even need to find the cell during mousemove just I want to find the number of row and make it highlight. But still, .mouserow shows some inconsistent value(say a decreasing series 9,8,7 and .mousecol =constant 1 even if I keep the mouse on some other column and some other row). Is there any bug in flexgrid to trace rows?

  12. #12
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    no bugs I know of. To highlight a row use the .Row and .SelRow properties (but read the documentation, I sort of remember that must be set in the right order)
    the only way to create an icon is a icon editor, I do not know if you can find one outside devstudio, try google for it. Btw you meant 16x16 pixels, not bits... I attached the bitmap that I use for the check ON mark, to give you an idea. It is a bitmap, not an icon, you can open and edit with ms paint
    Marco
    Attached Images Attached Images
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

Similar Threads

  1. Enable and Disable Checkbox in Datagrid
    By Brian in forum ASP.NET
    Replies: 2
    Last Post: 07-16-2008, 02:43 PM
  2. How to put checkbox on subitem of a listview
    By Danny in forum VB Classic
    Replies: 6
    Last Post: 08-01-2005, 02:19 PM
  3. ListView Control and Custom Sorting
    By Birhanu in forum VB Classic
    Replies: 0
    Last Post: 11-09-2001, 04:26 PM
  4. Listview boxes
    By Kenneth in forum VB Classic
    Replies: 0
    Last Post: 04-24-2001, 11:04 AM
  5. How to put checkbox on subitem of a listview
    By Danny in forum VB Classic
    Replies: 0
    Last Post: 02-27-2001, 10:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center