DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 8 of 8

Thread: Ideas Please

  1. #1
    Jeremy's Dad Guest

    Ideas Please

    I'm playing about with a small app and haven't any idea which control(s) I
    might use to complete it.

    In short, it's going to be a HTML FAQ generator. I want to have a control
    on the top into which I can add all the questions and a control on the
    bottom which would contain the answers. Ideally, it would save the data for
    future editing.

    So far, I've played about with the following ideas:

    Text box within the data repeater control for both Q & A
    Flexgrid for both Q & A

    The text box idea means I would have to get my head around two dimensional
    arrays (I've been wondering when I would get around to checking them out!!)
    while the Flex Grid is pretty much an array all on it's own.

    One thing has me confused about the flexgrid though. Which property do I
    set to allow input? My little test so far has not found any way to add text
    other than by code. Would I set up a text box into which I edit the text
    and then send it to the flexgrid?

    Looking forward to your ideas

    Gary



  2. #2
    Kathleen Dollard-Joeris Guest

    Re: Ideas Please

    Gary,

    I'd go with the grid for simplicity.

    You can overlay a text box over the cell of the grid.

    --
    Kathleen
    (MS-MVP)
    Reply in the newsgroup so everyone can benefit
    --
    Jeremy's Dad <jsdad@home.com> wrote in message
    news:39629383@news.devx.com...
    > I'm playing about with a small app and haven't any idea which control(s) I
    > might use to complete it.
    >
    > In short, it's going to be a HTML FAQ generator. I want to have a control
    > on the top into which I can add all the questions and a control on the
    > bottom which would contain the answers. Ideally, it would save the data

    for
    > future editing.
    >
    > So far, I've played about with the following ideas:
    >
    > Text box within the data repeater control for both Q & A
    > Flexgrid for both Q & A
    >
    > The text box idea means I would have to get my head around two dimensional
    > arrays (I've been wondering when I would get around to checking them

    out!!)
    > while the Flex Grid is pretty much an array all on it's own.
    >
    > One thing has me confused about the flexgrid though. Which property do I
    > set to allow input? My little test so far has not found any way to add

    text
    > other than by code. Would I set up a text box into which I edit the text
    > and then send it to the flexgrid?
    >
    > Looking forward to your ideas
    >
    > Gary
    >
    >




  3. #3
    Brent Guest

    Re: Ideas Please


    Or use one of the other grid controls, MSDataGrid that support editing directly
    within the grid...

    Or purchase a Third-party control that will enable you to create a very nice
    and clean interface.

  4. #4
    Patrick Marshall Guest

    Re: Ideas Please


    Hi,

    I posted a simple example for using a textbox
    to enter data in a MSFlexgrid at:

    http://news.devx.com/cgi-bin/dnewswe...em=41657&utag=

    <Patrick>

    "Kathleen Dollard-Joeris" <kjoeris@noemailplease.com> wrote:
    >Gary,
    >
    >I'd go with the grid for simplicity.
    >
    >You can overlay a text box over the cell of the grid.
    >
    >--
    >Kathleen
    >(MS-MVP)
    >Reply in the newsgroup so everyone can benefit
    >--



  5. #5
    Jeremy's Dad Guest

    Re: Ideas Please

    Patrick,

    > I posted a simple example for using a textbox
    > to enter data in a MSFlexgrid at:


    I get the following error when I try the code...

    "Compile Error, sub or function not defined".

    When I go back to the code, the following section is highlighted
    (underlined)

    Text1(0).Text = X & " " & Y
    ^^^^

    Keeping in mind this is the "getting started" group, let's see if I am
    reading that section of code right....

    The ".Text" property means this is identifying a control of some sort. A
    guess would be that it's a text box given it's name. Given your notes that
    the text box is actually called txtEditGrid, I am lost. Is there a second
    Text Box you failed to describe?

    Thanks

    Gary




  6. #6
    Rich Guest

    Re: Ideas Please


    >I get the following error when I try the code...
    >
    >"Compile Error, sub or function not defined".
    >
    >When I go back to the code, the following section is highlighted
    >(underlined)
    >
    > Text1(0).Text = X & " " & Y
    > ^^^^
    >
    >Keeping in mind this is the "getting started" group, let's see if I am
    >reading that section of code right....
    >
    >The ".Text" property means this is identifying a control of some sort.

    A
    >guess would be that it's a text box given it's name. Given your notes that
    >the text box is actually called txtEditGrid, I am lost. Is there a second
    >Text Box you failed to describe?
    >
    >Thanks
    >
    >Gary
    >
    >
    >


    The 'Text1(0).text = X & " " & Y' line of the previously posted code caused
    an error because, as you assumed, there were missing controls, 2 textboxes
    in fact. Both were called Text1, so forming a control array of two textboxes
    with indices 0 and 1. I don't know if you have dealt with control arrays
    before, but they are very powerful indeed. If you would like any information
    on how to create or use control arrays then email me and I'll try and help
    you.

    Back to the original query. Using FlexGrid.

    On a form add a FlexGrid control and set it's name to Grid1, then set the
    rows and cols values to whatever you want. Add a textbox and leave it's
    name as Text1, set it's visible property to False. Now paste the code below
    into the form code window. The UpdateCell boolean is necessary because if
    you highlight an entire row or column by clicking on the header cells, then
    when you click onto another cell or row/column header the value in the first
    cell of the row or column selected first will disappear. This is easier
    to see than explain, so try commenting out everything except the

    MSFlexGrid1.text = Text1.text

    line of the LeaveCell sub, and run the code.

    You will notice that this code does not allow editing of the row/col headers,
    to allow this you must completely remove the first if statement from the
    EnterCell sub, doing this also make sthe UpdateCell boolean and if statement
    redundant, so you can also remove them (leaving the MSFlexGrid1.Text = Text1.Text,
    and line in the LeaveCell sub). The code also takes into account that cell
    sizes can change, and will resize the textbox each time it is used.

    There are many things that you can add to the functionality of this, such
    as moving to the next cell when the user presses the enter key, by using
    the Text1_KeyPress event etc...


    Dim UpdateCell As Boolean

    Private Sub MSFlexGrid1_EnterCell()
    UpdateCell = True

    'Now make sure that the user isn't clicking on the row or column headers
    If MSFlexGrid1.MouseRow = 0 Or MSFlexGrid1.MouseCol = 0 Then
    UpdateCell = False
    Text1.Visible = False
    Exit Sub
    End If

    MSFlexGrid1.Row = MSFlexGrid1.MouseRow
    MSFlexGrid1.Col = MSFlexGrid1.MouseCol
    Text1.Text = ""

    'Put textbox over cell that user has chosen
    Text1.Visible = False
    Text1.Top = MSFlexGrid1.Top + MSFlexGrid1.CellTop
    Text1.Left = MSFlexGrid1.Left + MSFlexGrid1.CellLeft

    'Now change size of text box to match size of the cell
    Text1.Width = MSFlexGrid1.CellWidth
    Text1.Height = MSFlexGrid1.CellHeight

    'Put any contents of the cell into the text box for editing
    Text1.Text = MSFlexGrid1.Text

    'Display textbox and give it the focus for editing
    Text1.Visible = True
    Text1.SetFocus
    End Sub

    Private Sub MSFlexGrid1_LeaveCell()
    If UpdateCell Then
    MSFlexGrid1.Text = Text1.Text
    UpdateCell = False
    End If
    End Sub


    Hope this helps.

    Rich

  7. #7
    Rich Guest

    Re: Ideas Please


    "Rich" <richardcharles@excite.co.uk> wrote:
    >
    >>I get the following error when I try the code...
    >>
    >>"Compile Error, sub or function not defined".
    >>
    >>When I go back to the code, the following section is highlighted
    >>(underlined)
    >>
    >> Text1(0).Text = X & " " & Y
    >> ^^^^
    >>
    >>Keeping in mind this is the "getting started" group, let's see if I am
    >>reading that section of code right....
    >>
    >>The ".Text" property means this is identifying a control of some sort.


    >A
    >>guess would be that it's a text box given it's name. Given your notes

    that
    >>the text box is actually called txtEditGrid, I am lost. Is there a second
    >>Text Box you failed to describe?
    >>
    >>Thanks
    >>
    >>Gary
    >>
    >>
    >>

    >
    >The 'Text1(0).text = X & " " & Y' line of the previously posted code caused
    >an error because, as you assumed, there were missing controls, 2 textboxes
    >in fact. Both were called Text1, so forming a control array of two textboxes
    >with indices 0 and 1. I don't know if you have dealt with control arrays
    >before, but they are very powerful indeed. If you would like any information
    >on how to create or use control arrays then email me and I'll try and help
    >you.
    >
    >Back to the original query. Using FlexGrid.
    >
    >On a form add a FlexGrid control and set it's name to Grid1, then set the
    >rows and cols values to whatever you want. Add a textbox and leave it's
    >name as Text1, set it's visible property to False. Now paste the code below
    >into the form code window. The UpdateCell boolean is necessary because

    if
    >you highlight an entire row or column by clicking on the header cells, then
    >when you click onto another cell or row/column header the value in the first
    >cell of the row or column selected first will disappear. This is easier
    >to see than explain, so try commenting out everything except the
    >
    >MSFlexGrid1.text = Text1.text
    >
    >line of the LeaveCell sub, and run the code.
    >
    >You will notice that this code does not allow editing of the row/col headers,
    >to allow this you must completely remove the first if statement from the
    >EnterCell sub, doing this also make sthe UpdateCell boolean and if statement
    >redundant, so you can also remove them (leaving the MSFlexGrid1.Text = Text1.Text,
    >and line in the LeaveCell sub). The code also takes into account that cell
    >sizes can change, and will resize the textbox each time it is used.
    >
    >There are many things that you can add to the functionality of this, such
    >as moving to the next cell when the user presses the enter key, by using
    >the Text1_KeyPress event etc...
    >
    >
    >Dim UpdateCell As Boolean
    >
    >Private Sub MSFlexGrid1_EnterCell()
    >UpdateCell = True
    >
    >'Now make sure that the user isn't clicking on the row or column headers
    >If MSFlexGrid1.MouseRow = 0 Or MSFlexGrid1.MouseCol = 0 Then
    > UpdateCell = False
    > Text1.Visible = False
    > Exit Sub
    >End If
    >
    >MSFlexGrid1.Row = MSFlexGrid1.MouseRow
    >MSFlexGrid1.Col = MSFlexGrid1.MouseCol
    >Text1.Text = ""
    >
    >'Put textbox over cell that user has chosen
    >Text1.Visible = False
    >Text1.Top = MSFlexGrid1.Top + MSFlexGrid1.CellTop
    >Text1.Left = MSFlexGrid1.Left + MSFlexGrid1.CellLeft
    >
    >'Now change size of text box to match size of the cell
    >Text1.Width = MSFlexGrid1.CellWidth
    >Text1.Height = MSFlexGrid1.CellHeight
    >
    >'Put any contents of the cell into the text box for editing
    >Text1.Text = MSFlexGrid1.Text
    >
    >'Display textbox and give it the focus for editing
    >Text1.Visible = True
    >Text1.SetFocus
    >End Sub
    >
    >Private Sub MSFlexGrid1_LeaveCell()
    >If UpdateCell Then
    > MSFlexGrid1.Text = Text1.Text
    > UpdateCell = False
    >End If
    >End Sub
    >
    >
    >Hope this helps.
    >
    >Rich




    Sorry, don't rename the FlexGrid control, leave it as MSFlexGrid1 :-).

  8. #8
    Patrick Marshall Guest

    Re: Ideas Please


    Hi "Jeremy's Dad",

    > Text1(0).Text = X & " " & Y


    is just debug code for my internal use, I should
    have removed it before posting. Sorry, I didn't
    notice it was there. txtEditGrid is the ONLY control
    you need to add (other than your existing
    MSFlexgrid of course). Data entry occurs in the
    keyup and mouseup events of txtEditGrid,
    you didn't say exactly what you were doing with
    this so I omitted the code for that part (my
    example for this was specialized and probably
    would not have applied to you). If you need
    further help in this area please feel free to
    post again.

    <Patrick>

    "Jeremy's Dad" <jsdad@home.com> wrote:
    >Patrick,
    >
    >> I posted a simple example for using a textbox
    >> to enter data in a MSFlexgrid at:

    >
    >I get the following error when I try the code...
    >
    >"Compile Error, sub or function not defined".
    >
    >When I go back to the code, the following section is highlighted
    >(underlined)
    >
    > Text1(0).Text = X & " " & Y
    > ^^^^
    >
    >Keeping in mind this is the "getting started" group, let's see if I am
    >reading that section of code right....
    >
    >The ".Text" property means this is identifying a control of some sort.

    A
    >guess would be that it's a text box given it's name. Given your notes that
    >the text box is actually called txtEditGrid, I am lost. Is there a second
    >Text Box you failed to describe?
    >
    >Thanks
    >
    >Gary
    >
    >
    >



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