Different color text in one cell

How do I set a color for a group of words within a cell leaving the rest of the words black?
I can make all the text within a cell the same color but when I select the words I want to be a different color the color selector in the toolbar goes away and only fx, Cancel and Accept buttons are available.

If it is simple text, not the result of a formula, select the words you want to change and select another color from the toolbar or the color panel. That is, unless I didn't understand your request. I don't know where you are seeing Accept, Cancel and Fx.

Similar Messages

  • How to set different color text in JTabe cell

    Hi
    I have been searching many forums to find how can this be done, but no success.
    I have Custom JTable with MyTableRenderer which is nothing else but alternate the color of rows(cells), CustomTableModel extends DefaultTableModel adding functionality for updateCellContent with different messages.
    I have a column in which cells i want to set these messages in different color.They are not set by user's editing, and by updating the content using the table model.
    Here is the code for that
    public void updateCellContent(HashMap<String, String> messages, int col) {
            for (int row = 0; row < this.dataVector.size() - 1; row++) {
                //This value is hardcoded for now.
                boolean isError = true;
                String filename = getFilename(row);
                String message = messages.get(filename);
                if (message != null) {
                    if (isError) {
                        setErrorMessage(message, row);
                    } else {
                        setMessage(message, row);
        private void setErrorMessage(String message, int row) {
            this.setFileStatus(message, row);
        private void setMessage(String message, int row) {
            String value = (String) this.getValueAt(row, COL_FILE_STATUS);
            ((Vector) this.dataVector.get(row)).setElementAt(value + " " + message, COL_FILE_STATUS);
            fireTableCellUpdated(row, COL_FILE_STATUS);
    public void setFileStatus(String message, int row) {
            setValueAt(message, row, COL_FILE_STATUS);
        }Thanks
    Dimitar

    I have Custom JTable with MyTableRenderer which is nothing else but alternate the color of rows(cells)If I understand you correctly a better way to do this is to override the prepareRenderer(...) method of JTable. You can search the forum for my "Table Prepare Renderer" (without the spaces) example which shows how this can be done.
    I have a column in which cells i want to set these messages in different color.Then you need to use a custom renderer for that column.
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.

  • How to set two colored text in one textarea

    hello friends,
    i am busy preparing chat frame which shows messages in textarea, it shows two things, one the name of chatter , the other is the message, i want the two things of different color, you can change the text color of textarea by setForeground(), but what if i want different colored text in same textarea, can anybody help me???

    I don't know if this will help u...try make sense of it :
    DefaultStyledDocument doc = new DefaultStyledDocument();
    JTextPane tp = new JTextPane(doc);
    tp.setFont (new java.awt.Font ("Arial", 1, 12));
    JScrollPane lscroller = new JScrollPane(tp);
    lscroller.setForeground (new java.awt.Color (102, 102, 153));
    lscroller.setPreferredSize (new java.awt.Dimension(496, 273));
    lscroller.setVerticalScrollBarPolicy(
    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    jPanel2.add ( lscroller );
    prepareAllStyles();
    void prepareAllStyles()
    aset = new SimpleAttributeSet();
    //set bold and red
    StyleConstants.setForeground(aset,Color.black);
    StyleConstants.setBold(aset,true);
    ht.put(BOLDRED,aset);
    aset = new SimpleAttributeSet();
    //set italic and green
    StyleConstants.setForeground(aset,Color.red);
    StyleConstants.setBold(aset,true);
    ht.put(ITALICGREEN,aset);
    AttributeSet current = (AttributeSet)ht.get(BOLDRED);
    doc.insertString(doc.getLength(),displaymessage + "\n",current);
    tp.setCaretPosition( doc.getLength() );

  • Different color text in text area???????

    hi,
    i am working on applet in which i want to show different color text in text area????????
    could any one help me

    I'm not sure it replies, we have developed an
    editorkit for the JEditorPane for colorizing a
    text with a property file describing a grammar. We
    provide in the packaging a trivial sample
    for coloring a java syntax in an applet.
    http://www.japisoft.com/syntaxcolor
    And of course it also requires that you buy it, and a.brillant forgot to mention that a.brillant has a financial interest in this product.

  • Different coloured text in one Textbox

    Can someone PLEASE help me!!!!!!!!!!!!!!
    I need to know how to have different coloured text in the same textbox.
    My application has text being inputted into the textbox every 5 seconds from 2 different sources. I want to differenciate the text by showing the user 2 different colours for each source.
    Thank you very much

    Acording to the first post it also shows data, so it is a GUI component. i never sow a textbox.
    JTextPane can show data in different colors. also JTextArea can.
    Noah

  • How to color more than one cell in an ALV line ???

    Hi SDN community,
    I have the following problem:
    I display an internal table with the 'REUSE_ALV_GRID_DISPLAY' function and want to color two cells, not only one cell.
    Coloring one cell is no problem with...
    cell_color1 TYPE lvc_t_scol, " cell color
    DATA  gs_cellcolor    TYPE          lvc_s_scol. " to color a cell
    gs_cellcolor-fname = 'TNAME'.
    gs_cellcolor-color-col = '6'.
    gs_cellcolor-color-int = '1'.
    gs_cellcolor-color-inv = '0'.
    LOOP AT it_result.
      IF it_result-trend EQ 'fast-growing'.
        APPEND gs_cellcolor TO it_result-cell_color1.
        IF sy-subrc EQ 0.
          MODIFY it_result.
        ENDIF.
      ENDIF.
    ENDLOOP.
    and
    ls_layout-coltab_fieldname = 'CELL_COLOR1'.
    , the last one is in the layout building form.
    My problem is that in
    ls_layout-coltab_fieldname = 'CELL_COLOR1'.
    , I can only type in ONE fieldname, but I would like to color more than one field/cell, you got my problem?
    Thank you very much,
    Marius

    I'm pretty sure that the color would be controlled by what records are appended to the CELL_COLOR1 table inside IT_RESULT. . So move the code inside the IF statement, and add addition logic.
    LOOP AT it_result.
      IF it_result-trend EQ 'fast-growing'.
       gs_cellcolor-fname = 'TNAME'.
       gs_cellcolor-color-col = '6'.
       gs_cellcolor-color-int = '1'.
       gs_cellcolor-color-inv = '0'.
        APPEND gs_cellcolor TO it_result-cell_color1.
        IF sy-subrc EQ 0.
          MODIFY it_result.
        ENDIF.
    else.
       gs_cellcolor-fname = 'OTHER_FIELD'.
       gs_cellcolor-color-col = '5'.
       gs_cellcolor-color-int = '1'.
       gs_cellcolor-color-inv = '0'.
        APPEND gs_cellcolor TO it_result-cell_color1.
        IF sy-subrc EQ 0.
          MODIFY it_result.
        ENDIF.
      ENDIF.
    ENDLOOP.
    Regards,
    Rich Heilman

  • Compare text in one cell to a range of cells, get interger count of values

    Hi there,
    Basically what I'd like to do is, as a value in one cell, compare the text in a second cell to a range of third cells, and get a count of "hits".
    EXACT(second,third) will compare two cells, return a boolean. How do I batch run EXACT, and force boolean values into integers.
    Conceptually:
    For each J2:J14;$X=$X+INT(EXACT(B2,$_);return $X
    Can this be done in Numbers?

    Nevermind; the following works:
    =COUNTIF(($J2:$J14),B1)

  • How can I correct for 2 different color temperatures in one image?

    Hi,
    In indoor architectural photography one may encounter mixed color temperatures in one image. If one could use gels and lamps to replace incoming natural daylight and force a uniform color temperature (for instance tungsten) then the problem would go away. Yet, sometimes this is not possible or practical and I was exploring what could be accomplished within Photoshop. Here is my proposal ( or beginning of it):
    shoot RAW
    generate 2 versions of the image, each corrected for one of the color temperatures present (say WB dropper in "should be neutral" area where daylight dominates and another WB dropper in "should be neutral" area where tungsten dominates)
    open them in Photoshop and move one of them as a layer on top of the other version
    Try to blend the two layers
    in one example, I used Hue blending mode and the photo fixed itself!! However this is not generalizable to other images
    I also tried BlendIf for harder images but with no success
    I presume selection is then a must which brings up the question:HOW CAN I SELECT DEPENDING ON COLOR TEMPERATURE? I mean, the layer where WB = daylight looks orange-casted in the areas where the main light source is tungsten, while the layer where WB = tungsten looks blue-casted in the areas lit mainly by sunlight. I must believe there should exist a best approach to select say the blue-casted areas or the orange-casted areas, and that approach should be simple if it somehow takes into consideration the predominant cast. I have tried Select Color Range but not very successfully. I just feel there must be a simpler way, taking advantage of the present casts.
    Masks seem also useful
    All feedback will be greatly appreciated!
    Thanks,
    Juan

    If you want to use multiple keepalives for a service, you must use a script. The alternative would be to create 2 content rules, and 2 sets of services, one for port 80 (or whatever) and one for port 443 (or whatever), and use http for one and ssl for the other.
    Michael Voight
    CSE

  • How to change color of text in one cell of a List component?

    I tried this but didn't work:
    list.getItemAt(2).textField.setStyle("textFormat", tf);
    Thanks!!

    Shy layers?  I see the words "Music Party" in two text layers in the timeline.  Here's what you do:
    Double-click on one of the text layers to highlight all the characters in the layer.  Go to the Character Pane and change the color.  Double-click on the other text layer.  Instead of changing the color in the Character pane, use the eyedropper to match the color of the first layer.
    Easy as pie.

  • Need formula to take text from one cell, add that to a serial number with leading zeros

    I'm trying to create a spreasdheet cell that simplifies creating videotape Numbers from a job name in cell and appends a serial number with leading zeros, and that would survive an export to EXCEL.
    The result would look like
     A Column
    Job Name
    B ColumnTape #
    Formula needed for B
    ClientName-TapeType-
    ClientName-TapeType-001
    =
    ClientName-TapeType-
    ClientName-TapeType-002
    =
    I've tried using a custom cell format that had the text in front of the (Integer) drag and drop, with three integers and leading zeros.
    That worked, but requires recreating the custom cell format for each client and tape type.
    So, I've used the formula =A2& in order to play around with different things, but haven't hit on something that adjusts for increased numbers and retains the leading zeros.
    I don't mind doing a starter for the first row and then adding +1 in the formulas for the rows below.
    I've done that using the custom cell formats for the first B cell and then using =Bx+1 in the following cells.  It works, but I'm hoping to find something simpler or that can be copied and pasted in multiple rows on one paste.
    Thanks in advance.
    Suggestions much appreciated!
    Ted

    Ted,
    This expression in B will give you the pattern I believe you are looking for:
    =A&RIGHT("00"&ROW()-1, 3)
    Here's a screen shot...
    Jerry

  • When i paste some copied color text or formatted cells from excel to my mail draft while composing a mail, it is being pasted as plain text. No back groud or text colors are copied to it. Please suggest a possible solution for this issue.

    Colors & Formatted Cells from Excel application can not be copied to my mail composer as it is. Only Plain text is copied.

    Wish I could be king. But you described the problem perfectly and I am still but a pawn. All I can say is that I trashed the mail preferences (com.apple.mail.plist) on my Mac Mini, and now my MacBook seems to work right.
    Sorry. :>) But that is the truth... The MacBook now has actually sometimes displayed pasted text in its actual, different, font and style as I paste it into a partially composed new mail message.
    In other (more rational) words, the problem seems to be tied to pasting only certain types of text. I have not been able yet to pinpoint what. Yes, frustrating indeed. The only work-around has been to re-train my fingers to command-option-shift V, for "paste and match style" (like you, I do not want to always use only plain text). Maybe someone else will eventually weigh in with a real solution. The solution I want is just to be able to consistently see any font variations within my message before I send the email.
    The info about the different ppi scales between Windows and Mac is interesting, although not relevant to this particular problem. It does explain the apparent overall size differences I have seen before.

  • Different Color Text of Topic Titles by Child Project in Search Results List

    Does anyone know how I can change the text color to indicate the source project of a topic as displayed in the Search Results list?
    I have followed Peter Grainge's directions for setting up a parent project that has several child projects, one of which contains outdated version-specific information. Thanks, Peter!
    I would like it to be obvious to the user before they open a topic from the Search Results list that it is from the old legacy project.
    I have found where the font is set, (thanks to the RoboWizard), but I am not a Javascript programmer and am uncertain how to code the "if document is from this project, then use this font" logic.
    I would also like to put a "caption" below the "Search Results per page" line to explain the purpose of the color change.
    I am using RoboHelp HTML 8.0.2. I generate WebHelp output which is then FTP'd to our server.
    Thanks in advance!

    Hi Leon,
         Let me make sure that I understand your suggestion - I should change the title of each topic in the "legacy" knowledge base so that they each include a short identifier, such as "First Topic - Legacy"? If so, I suppose that would work, but I'd have to change 1,000 topics. The topic titles would no longer match the filenames (I'm trying to freeze changes to the old knowledge base to which there are many links from our user forum), which I suppose is not a big concern at this point.  I'll run some tests.
         That has also raised another question in my mind, but I'll post that separately. It's about the way Robohelp selects the text that is shown immediately after the title of the topic in the Search Results list.
         Thanks for taking the time to help!

  • Coloring text in table cells depending on what text appears

    I have a table where some entries say 'success' and others say 'failure.' I want the 'success' to appear in green and the 'failure' to appear in red.
    This code doesn't work:
            model = new JTTableModel();
            JTable resultsTable = new JTable(model);
            resultsTable.setDefaultRenderer(Object.class,
                    new ColorRenderer());
        public class ColorRenderer extends JLabel implements TableCellRenderer {
            public java.awt.Component getTableCellRendererComponent(JTable table, Object value,
                    boolean isSelected, boolean hasFocus,
                    int row, int column) {
                System.out.println("value " +value+ " class of value "+value.getClass().getName());
                if (value.equals("success")){
                    setForeground(new Color(0,255,0));
                }else if (value.equals("failed")){
                    setForeground(new Color(255,0,0));
                return this;
        }What am I doing wrong?

    But lmgtfy is rude, No it isn't. Most posters are too lazy to search for themselves. There are hundreds of examples of renderers to be found in the forums here. Many times is it faster for us to point to links that have the answser rather then spend time explaining everything you have done wrong. You are not the only person we help.Then why not post the link to the Google search directly? No, lmgtfy is not about simply posting a link, it's about posting a link in a way that says, 'You're too stupid to use Google, so I'll do it for you.' Which is rude. No Duke points, sorry.
    As for searching this forum, the quality of search results here is definitely poor. How many screens of results should I search to find an example of what I need? Maybe I'm spoiled by Google, or maybe they should open this forum to Google search, and make the wisdom here accumulated more available.
    but if you note the time this was posted,We have no idea where you live or what time of day it is for you.Yes you do, if I set the time zone on my profile.
    This is my last post on this thread. I'm not going to bicker with you.

  • JTable with multiple colors in one cell

    Hello.
    I'm looking for a way to display colorized text inside one column of my table.
    For Example using the String: "^6en^3try"
    I want ^1 to ^7 to be colorcodes for different colors, so that the substring "en" is displayed in pink and the substring "try" in blue.
    I tried finding a solution for this on the net, but only found two general ideas on how to accomplish that:
    - "custom cell renderer for the column"
    - "put html in the cells"
    Now I've never worked with a custom cell renderer and I think using html could be a little too much for such a "simple" task.
    Any ideas on which way to go and how to do it?

    You can use DefaultTableCellRenderer
    for example
    private class ColorCellRenderer extends DefaultTableCellRenderer{
    public void setValue(Object value) {
    String cellData = value.toString();
    cellData = cellData.trim();
    if(cellData.equals("some condition")) {
    setForeground(Color.BLUE);
    ................ write your code
    set the default renderer using
    setDefaultRenderer
    u can use some thing like this
    super.setDefaultRenderer(ColorCell.class, new ColorCellRenderer());
    ColorCell extends Object {}
    and override the getColumnClass method in the table model class to get the custom class
    Hope this will help u
    Edited by: RA----------------AK on Mar 25, 2010 12:35 AM

  • ALV : color one cell

    Hi all,
    i want to color just only one cell in my ALV report, but i don't know how can i do that.
    Here my code :
    REPORT  ztest_alv_color_cell.
    Used to limit user commands on selection-screen
    INCLUDE rsdbc1xx.
    DATA: BEGIN OF i_alv OCCURS 0,
          connid   TYPE sflight-connid,
          currency TYPE sflight-currency,
          FLDATE   TYPE sflight-fldate,
          END OF i_alv.
    DATA: alv_grid       TYPE REF TO cl_gui_alv_grid.
    DATA: fieldcat  TYPE lvc_t_fcat.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001 .
    SELECT-OPTIONS: s_matnr FOR i_alv-connid.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF SCREEN 1010.
    SELECTION-SCREEN END OF SCREEN 1010.
    Events
    AT SELECTION-SCREEN OUTPUT.
      IF sy-dynnr = '1010'.
        current_scr-mode = 'S'.
        APPEND 'SPOS' TO current_scr-excl.
        APPEND 'SCRH' TO current_scr-excl.
        APPEND 'ONLI' TO current_scr-excl.
      ENDIF.
    START-OF-SELECTION.
      PERFORM get_data.
      CREATE OBJECT alv_grid
             EXPORTING
                   i_parent           =  cl_gui_container=>screen0.
    Populate Field Catalog
      PERFORM get_fieldcatalog.
      CALL METHOD alv_grid->set_table_for_first_display
        CHANGING
          it_outtab       = i_alv[]
          it_fieldcatalog = fieldcat[].
      CALL SELECTION-SCREEN 1010.
    FORM GET_DATA
    FORM get_data.
      SELECT * INTO CORRESPONDING FIELDS OF TABLE i_alv
            FROM sflight.
      SORT i_alv ASCENDING BY connid.
    ENDFORM.                    "get_data
         Form  Get_Fieldcatalog - Set Up Columns/Headers
    FORM get_fieldcatalog.
      DATA: ls_fcat TYPE lvc_s_fcat.
      REFRESH: fieldcat.
      CLEAR: ls_fcat.
      ls_fcat-reptext    = 'Connid'.
      ls_fcat-coltext    = 'Connid'.
      ls_fcat-fieldname  = 'CONNID'.
      ls_fcat-ref_table  = 'I_ALV'.
      ls_fcat-outputlen  = '10'.
      ls_fcat-col_pos    = 1.
      APPEND ls_fcat TO fieldcat.
      CLEAR: ls_fcat.
      ls_fcat-reptext    = 'Currency'.
      ls_fcat-coltext    = 'Currency'.
      ls_fcat-fieldname  = 'CURRENCY'.
      ls_fcat-ref_table  = 'I_ALV'.
      ls_fcat-outputlen  = '10'.
      ls_fcat-col_pos    = 2.
      APPEND ls_fcat TO fieldcat.
      CLEAR: ls_fcat.
      ls_fcat-reptext    = 'Flight date'.
      ls_fcat-coltext    = 'Flight date'.
      ls_fcat-fieldname  = 'FLDATE'.
      ls_fcat-ref_table  = 'I_ALV'.
      ls_fcat-datatype   = 'DATS'.
      ls_fcat-outputlen  = '10'.
      ls_fcat-col_pos    = 3.
      APPEND ls_fcat TO fieldcat.
    ENDFORM.                    "get_fieldcatalog
    Imagine that i want to color in red line 1 column 1, please tell how can i do this.
    Thanks very much for help.
    Cheers

    Hi,
    Check this code..
    REPORT  ZTEST1234    MESSAGE-ID ZZ                           .
    DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
    DATA: L_VALID TYPE C,
          V_FLAG,
          V_DATA_CHANGE,
          V_ROW TYPE LVC_S_ROW,
          V_COLUMN TYPE LVC_S_COL,
          V_ROW_NUM TYPE LVC_S_ROID.
    *       CLASS lcl_event_handler DEFINITION
    CLASS LCL_EVENT_HANDLER DEFINITION .
      PUBLIC SECTION .
        METHODS:
    **Hot spot Handler
        HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
                          IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,
    **Double Click Handler
        HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
                                         IMPORTING E_ROW E_COLUMN ES_ROW_NO.
    ENDCLASS.                    "lcl_event_handler DEFINITION
    *       CLASS lcl_event_handler IMPLEMENTATION
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
    *Handle Hotspot Click
      METHOD HANDLE_HOTSPOT_CLICK .
        CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
        V_ROW  = E_ROW_ID.
        V_COLUMN = E_COLUMN_ID.
        V_ROW_NUM = ES_ROW_NO.
        MESSAGE I000 WITH V_ROW 'clicked'.
      ENDMETHOD.                    "lcl_event_handler
    *Handle Double Click
      METHOD  HANDLE_DOUBLE_CLICK.
      ENDMETHOD.                    "handle_double_click
    ENDCLASS.                    "LCL_EVENT_HANDLER IMPLEMENTATION
    *&             Global Definitions
    DATA:      G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"Container1
                G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler
    DATA: OK_CODE LIKE SY-UCOMM,
          SAVE_OK LIKE SY-UCOMM,
          G_CONTAINER1 TYPE SCRFNAME VALUE 'TEST',
          GS_LAYOUT TYPE LVC_S_LAYO.
    *- Fieldcatalog for First and second Report
    DATA: IT_FIELDCAT  TYPE  LVC_T_FCAT,
          X_FIELDCAT TYPE LVC_S_FCAT,
          LS_VARI  TYPE DISVARIANT.
    *                START-OF_SELECTION
    START-OF-SELECTION.
      DATA:BEGIN OF  ITAB OCCURS 0,
           VBELN LIKE LIKP-VBELN,
           POSNR LIKE LIPS-POSNR,
           CELLCOLOR TYPE LVC_T_SCOL, "required for color
           DROP(10),
           END OF ITAB.
      SELECT VBELN
             POSNR
             FROM LIPS
             UP TO 20 ROWS
             INTO CORRESPONDING FIELDS OF TABLE ITAB.
    END-OF-SELECTION.
      IF NOT ITAB[] IS INITIAL.
        CALL SCREEN 100.
      ELSE.
        MESSAGE I002 WITH 'NO DATA FOR THE SELECTION'(004).
      ENDIF.
    *&      Form  CREATE_AND_INIT_ALV
    *       text
    FORM CREATE_AND_INIT_ALV .
      DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
      CREATE OBJECT G_CUSTOM_CONTAINER
             EXPORTING CONTAINER_NAME = G_CONTAINER1.
      CREATE OBJECT G_GRID
             EXPORTING I_PARENT = G_CUSTOM_CONTAINER.
    * Set a titlebar for the grid control
      CLEAR GS_LAYOUT.
      GS_LAYOUT-GRID_TITLE = TEXT-003.
      GS_LAYOUT-ZEBRA = SPACE.
      GS_LAYOUT-CWIDTH_OPT = 'X'.
      GS_LAYOUT-NO_ROWMARK = 'X'.
      GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
      CALL METHOD G_GRID->REGISTER_EDIT_EVENT
        EXPORTING
          I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER.
      CREATE OBJECT G_HANDLER.
      SET HANDLER G_HANDLER->HANDLE_DOUBLE_CLICK FOR G_GRID.
      SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR G_GRID.
      DATA: LS_CELLCOLOR TYPE LVC_S_SCOL. "required for color
      DATA: L_INDEX TYPE SY-TABIX.
      "Here i am changing the color of line 1,5,10...
      "so you can change the color of font conditionally
      LOOP AT ITAB.
        L_INDEX = SY-TABIX.
        IF L_INDEX = 1 OR L_INDEX = 5 OR L_INDEX = 10.
          LS_CELLCOLOR-FNAME = 'VBELN'.
          LS_CELLCOLOR-COLOR-COL = '6'.
          LS_CELLCOLOR-COLOR-INT = '0'.
          LS_CELLCOLOR-COLOR-INV = '1'.
          APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
          MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
          LS_CELLCOLOR-FNAME = 'POSNR'.
          LS_CELLCOLOR-COLOR-COL = '6'.
          LS_CELLCOLOR-COLOR-INT = '0'.
          LS_CELLCOLOR-COLOR-INV = '1'.
          APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
          MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
        ENDIF.
      ENDLOOP.
    * setting focus for created grid control
      CALL METHOD CL_GUI_CONTROL=>SET_FOCUS
        EXPORTING
          CONTROL = G_GRID.
    * Build fieldcat and set editable for date and reason code
    * edit enabled. Assign a handle for the dropdown listbox.
      PERFORM BUILD_FIELDCAT.
      PERFORM  SET_DRDN_TABLE.
    * Optionally restrict generic functions to 'change only'.
    *   (The user shall not be able to add new lines).
      PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
    **Vaiant to save the layout
      LS_VARI-REPORT      = SY-REPID.
      LS_VARI-HANDLE      = SPACE.
      LS_VARI-LOG_GROUP   = SPACE.
      LS_VARI-USERNAME    = SPACE.
      LS_VARI-VARIANT     = SPACE.
      LS_VARI-TEXT        = SPACE.
      LS_VARI-DEPENDVARS  = SPACE.
    **Calling the Method for ALV output
      CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
          IS_VARIANT           = LS_VARI
          IS_LAYOUT            = GS_LAYOUT
          I_SAVE               = 'A'
        CHANGING
          IT_FIELDCATALOG      = IT_FIELDCAT
          IT_OUTTAB            = ITAB[].
    * Set editable cells to ready for input initially
      CALL METHOD G_GRID->SET_READY_FOR_INPUT
        EXPORTING
          I_READY_FOR_INPUT = 1.
    ENDFORM.                               "CREATE_AND_INIT_ALV
    *&      Form  EXCLUDE_TB_FUNCTIONS
    *       text
    *      -->PT_EXCLUDE text
    FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
    * Only allow to change data not to create new entries (exclude
    * generic functions).
      DATA LS_EXCLUDE TYPE UI_FUNC.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
    ENDFORM.                               " EXCLUDE_TB_FUNCTIONS
    *&      Form  build_fieldcat
    *       Fieldcatalog
    FORM BUILD_FIELDCAT .
      DATA: L_POS TYPE I.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Delivery'(024).
      X_FIELDCAT-FIELDNAME = 'VBELN'.
      X_FIELDCAT-TABNAME = 'IT_FINAL'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-NO_ZERO    = 'X'.
      X_FIELDCAT-OUTPUTLEN = '10'.
      X_FIELDCAT-HOTSPOT = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Item'(025).
      X_FIELDCAT-FIELDNAME = 'POSNR'.
      X_FIELDCAT-TABNAME = 'IT_FINAL'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '5'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Drop'(025).
      X_FIELDCAT-FIELDNAME = 'DROP'.
      X_FIELDCAT-TABNAME = 'IT_FINAL'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '5'.
      X_FIELDCAT-EDIT = 'X'.
      X_FIELDCAT-DRDN_HNDL = '1'.
      X_FIELDCAT-DRDN_ALIAS = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
    ENDFORM.                    " build_fieldcat
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAIN100'.
      IF G_CUSTOM_CONTAINER IS INITIAL.
    **Initializing the grid and calling the fm to Display the O/P
        PERFORM CREATE_AND_INIT_ALV.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  SET_DRDN_TABLE
    *       text
    FORM SET_DRDN_TABLE.
      DATA:LT_DRAL TYPE LVC_T_DRAL,
            LS_DRAL TYPE LVC_S_DRAL.
      LOOP AT ITAB .
    * First listbox (handle '1').
        IF SY-INDEX = 1.
          LS_DRAL-HANDLE = '1'.
          LS_DRAL-VALUE =  ' '.
          LS_DRAL-INT_VALUE =  ' '.
        ELSE.
          LS_DRAL-HANDLE = '1'.
          LS_DRAL-VALUE =  ITAB-POSNR.
          LS_DRAL-INT_VALUE =  ITAB-POSNR.
        ENDIF.
        APPEND LS_DRAL TO LT_DRAL.
      ENDLOOP.
    **Setting the Drop down table for Reason Code
      CALL METHOD G_GRID->SET_DROP_DOWN_TABLE
        EXPORTING
          IT_DROP_DOWN_ALIAS = LT_DRAL.
    ENDFORM.                               " set_drdn_table
    Regards
    vijay

Maybe you are looking for