How to select a random cell in the DataGridView?

Good day
I am new to the DataGridView control. I was wondering if one can select a random cell in the DataGridView and if it is possible can someone help me with the code or a link to do it please.
Thank you.

Hi Arno du Toit,
Use the following code, you can select the specilized cell.
DataGridView1.CurrentCell = DataGridView1.Rows[rowindex].Cells[columnindex];
Select a random Cell?
Random rnd = new Random();
int rowMax = DataGridView1.Rows.Count;
int colMax = DataGridView1.Columns.Count;
if(rowMax > 0 && colMax > 0)
int row = rnd.Next(1, rowMax); //get the random row index
int column = rnd.Next(1, colMax); //get the random column index
DataGridView1.CurrentCell = DataGridView1.Rows[row].Cells[column];
If you have any other concern regarding this issue, please feel free to let me know.
Best regards,
Youjun Tang
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • How do you highlight several cells with the mouse in numbers

    how do you highlight several cells with the mouse in numbers

    Hi David,
    Using only the mouse, you can select a contiguous range of cells using the method described by dwb.
    For larger (but still contiguous) ranges you might prefer this method:
    Click the first (top left) cell of the desired selection.
    Scroll to the last (botom right) cell of the desired selection.
    Shift-click the bottom right cell to select it, and all of the cells in the rectangular array defined by this and the top left cell selected in step 1.
    To select two or more non-contiguous cells:
    Click on the first to select it.
    Command-click on another to add it to the selection.
    Repeat as necessary.
    Regards,
    Barry

  • How to set colors in cells depending the conditions  in alvtree

    Hi All,
    Could you please provide me idea or sample program how to set colors in cells depending the conditions  in alvtree.
    Thanks,
    Suresh

    When running vim in a terminal, it will use whatever colour scheme is defined by the terminal.  You should have a look at this thread:
    http://bbs.archlinux.org/viewtopic.php?id=51818
    Also, check the wiki article on Xdefaults.

  • How do you add multiple cells to the LARGE function?

    I want to add several cells which are contained on different sheets and tables to the same LARGE function and select the first ranking cell value.
    How do I add these cells as a single argument for this function?

    "...and select the first ranking cell value."
    Hi eobet,
    If your actual goal is as stated, you could use MAX, which will accept a list, a range, or a list of ranges as arguments.
    LARGE accepts only a single argument to establish the set of values, plus a single argument to establish the rank of the desired value. That means you need to collect all of the vlues into a sngle contiguous group/range, then specify that range as the set. The avantage, ofcourse, is that with LARGE, you can specify that you want the 'third largest' value in the set.
    Here's an example.
    The data set is column B on tables Data 1 and Data 2.
    The set is collected into a single contiguous range on the table Aux (which may be hidden, or placed on a separate sheet).
    LARGE collects the nth value from the collected set in Aux, using this formula in the table Summary:
    A2, and filled down: =LARGE(Aux :: A:B,ROW()-1)
    MAX returns the largest value from the original data set on Data 1 and Data 2, using this formula on the table Summary-1:
    A2: =MAX(Data 1 :: B,Data 2 :: B)
    Regards,
    Barry

  • How to select a random row with for update?

    Hi,
    I have a package that needs to assign a random, reusable number (ID) that is not currently being used - to a procedure.
    I'm trying to simulate a pool of numbers (IDs) using a table that has an ID and IS_USED columns.
    How do I do:
    select a random ID (random row)
    from pool_table
    where IS_USED is 0 (not taken)
    FOR UPDATEThe for update is to lock the row from being taken by another process calling the package.
    OR:
    Can I simulate a pool of numbers with a different object (not a table)?
    I need the numbers to be coherent between sessions (thus package variables will not work) and only one session uses the same ID at any given time. When it finishes the number becomes available for further runs.
    Thanks.
    Edited by: Pyrocks on Nov 7, 2010 10:45 AM

    This works on Oracle 11g (probably on 10g too, but I haven't tested):
    CREATE OR REPLACE PACKAGE REUSABLE_RANDOM_NUMBERS
    IS
      FUNCTION GET_NUMBER RETURN NUMBER;
    END REUSABLE_RANDOM_NUMBERS;
    create or replace
    PACKAGE BODY REUSABLE_RANDOM_NUMBERS
    IS
      TYPE NUM_TABLE_TYPE IS TABLE OF CHAR INDEX BY PLS_INTEGER;
      MIN_VALUE CONSTANT PLS_INTEGER := 0;
      max_value CONSTANT PLS_INTEGER := 10;
      NUM_TABLE NUM_TABLE_TYPE;
      FUNCTION GET_NUMBER RETURN NUMBER
      IS
        num PLS_INTEGER;
      BEGIN
        FOR I IN 1 .. 100 LOOP
           NUM := DBMS_RANDOM.VALUE( min_value, max_value );
           IF NOT NUM_TABLE.EXISTS( NUM ) THEN
              NUM_TABLE( NUM ) := 'X';
              RETURN NUM;
           END IF;
        END LOOP;
        FOR I IN MIN_VALUE .. MAX_VALUE LOOP
          IF NOT NUM_TABLE.EXISTS( i ) THEN
              NUM_TABLE( i ) := 'X';
              RETURN i;
           END IF;
        END LOOP;
        RAISE_APPLICATION_ERROR( -20991, 'All possible values have ben used, cannot assign a new one' );
      END;
    END REUSABLE_RANDOM_NUMBERS;
    SELECT REUSABLE_RANDOM_NUMBERS.GET_NUMBER
    FROM DUAL
    connect by level <= 11;
    GET_NUMBER            
    3                     
    4                     
    6                     
    2                     
    1                     
    7                     
    8                     
    0                     
    9                     
    5                     
    10                    
    11 rows selected
    SELECT REUSABLE_RANDOM_NUMBERS.GET_NUMBER
    FROM DUAL;
    Error starting at line 44 in command:
    SELECT REUSABLE_RANDOM_NUMBERS.GET_NUMBER
    FROM DUAL
    Error report:
    SQL Error: ORA-20991: All possible values have ben used, cannot assign a new one
    ORA-06512: przy "TEST.REUSABLE_RANDOM_NUMBERS", linia 26

  • How to select an individual cell in ALV.

    hi all,
    could anyone please tell me how do i select only one cell in a coloumn to perform the required operation on that cell.
    thanks.

    Hi Jagruti.
    If you search the forum with the key words: 'alv cell color' you will find the answer to
    this questions.
    Cheers,
    Sascha
    Message was edited by:
            Sascha Dingeldey

  • How to select a specific cell in a JTable?

    Hi there,
    in a JTable, I would like to select a specific cell (to highlight it) from a JButton.
    Here a sample code...
    Who could help me to fill it?
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.awt.*;
    import java.awt.event.*;
    public class TableSelection{
        public static void main (String args[]) {
          JFrame frame = new MyFrame();
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.show();
    class MyFrame extends JFrame{
      public MyFrame(){
        setTitle("TableSelection");
        setSize(WIDTH,HEIGHT);
        DefaultTableModel myModel = new DefaultTableModel(2,2);
        JTable myTable = new JTable(myModel);
        myTable.setCellSelectionEnabled(true);
        JButton button00 = new JButton("select 0,0");
        button00.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent event){
         System.out.println("selection of cell (0,0)");
         //--- what code is required to select the cell(0,0)?
        JButton button11 = new JButton("select 1,1");
        button11.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent event){
         System.out.println("selection of cell (1,1)");
         //--- what code is required to select the cell(1,1)?
        Box myBox = new Box(BoxLayout.Y_AXIS);
        myBox.add(new JScrollPane(myTable));
        myBox.add(button00);
        myBox.add(button11);
        getContentPane().add(myBox, BorderLayout.CENTER);
      private static final int WIDTH=200;
      private static final int HEIGHT=200;
    }Thanks a lot for your help.
    Denis

    Use the addColumnSelectionInterval(int index1, int index2)method ~ http://java.sun.com/j2se/1.4/docs/api/javax/swing/JTable.html#addColumnSelectionInterval(int,%20int)
    and the addRowSelectionInterval(int index1, int index2) method ~ http://java.sun.com/j2se/1.4/docs/api/javax/swing/JTable.html#addRowSelectionInterval(int,%20int)
    Hope that helped.
    afotoglidis

  • How do I make a cell reference the condition in a COUNTIF statement?

    I have a formula:
    =COUNTIF(Funds Under Management by Client :: D2:D91,">3.0")
    However, I want to replace the condition '3.0' with a reference to another cell eg B2 so that I can play around with different values and have them immediately reflected in the COUNTIF total. Problem is, I can't find the right syntax to achieve this. I want the formula to actually look something like this:
    =COUNTIF(Funds Under Management by Client :: D2:D91,">B2")
    Is this possible, and if so, how do I do it? Making the formula refer to a cell saves me from having to manually change 90 odd cells in the spreadsheet every time I want to vary the criteria.
    TIA
    Message was edited by: Basilisk

    Fantastic! That worked great. Many thanks for your help. Simple when you know how!
    Message was edited by: Basilisk

  • How to select values frm table giving the condition value at runtime in SQL

    Hi All,
    How to select values from a table by giving the condition value at runtime in SQL
    My SQL statement is select * from employee where empno=<empno>, this empno I want to provide at run time. Also I don't have any bind variables defined. Can anyone please tell how can I achieve this. Also do I have to write a SQL or pl/sql statement.

    Hi Roshni Shankar,
    You can use substitution variable in case of SQL.
    SQL> select * from employees where emplployee_id = &emp_id;
    Enter value for emp_id: 100
    old   1: select * from employees where emplployee_id = &emp_id
    new   1: select * from employees where emplployee_id = 100If you want to put condition on varchar values then eighter provide values in single quotes or use single quote for substitution variable.
    SQL> select * from employees where last_name = &emp_name;
    Enter value for emp_name: 'King'
    old   1: select * from employees where last_name = &emp_name
    new   1: select * from employees where last_name = 'King'
    no rows selected
    SQL> select * from employees where last_name = '&e_name';
    Enter value for e_name: King
    old   1: select * from employees where last_name = '&e_name'
    new   1: select * from employees where last_name = 'King'In case of pl/sql you can pass values to procedure and you can use those values at run time.
    create or replace procedure test (p_emp_id number)
    as
       v_last_name      varchar2(100);
    begin
       select last_name
       into    v_last_name
       from  employees
       where employee_id = p_emp_id;
       dbms_output.put_line(p_emp_id ||'    ->    '||v_last_name);
    end;
    show errors
    SQL>exec test(100);
    SQL>exec test(101);Edited by: Gaurav Bhide on Oct 29, 2012 4:07 AM

  • How to select values if I know the fieldname in PL*SQL? [SOLVED]

    There was a simple trick in SQL*PLUS:
    DEFINE var='EMP_NUMBER';
    SELECT &var FROM emp;
    And the result was the same as:
    SELECT emp_number FROM emp;
    Does anybody know how to write this in PL*SQL procedure? I didn't find any similar things in forum... I have db8i and 10g.
    m.

    Thank's a lot! I found this usefull article on Metalink as well:
    Subject: Dynamic SQL
    Doc ID: Note:62592.1 Type: BULLETIN
    Last Revision Date: 06-MAR-2007 Status: PUBLISHED

  • How to select all single values in the header area

    Dear Experts
    I got a request that the user wants to select a single value or all single values in the header area. E.g. if the values from characteristic master data are A, B, C and D, the selection can be one of these values or all of them. With the standard BPS configuration, due to the unique combination in the header area, selection of  'All' single values is not possible. Is there a way to select all single values in the header area?
    Thanks, Jessica

    Hi Jessica,
    Here is a solution where you need not to change your planning layout or to create a new variable or any exit function.
    Step 1 - Maintain master data value 'ALL' in the required characteristic.
    Step 2 - Create a copy function to copy all the required data records to 'ALL'. you can use standard copy function where you have to include only this characteristic in the fields to be change.
    Copy -
    From = all values (A,B,C,D etc)
    To = "ALL".
    Step 3 - Call this function on layout opening. you can include it in the planning folder and change the function attribute to call it on layout opening.
    Step 4 - Create a standard Delete function. you have to call this function on save operation. In this function, you have to delete all data records present in the buffer where required char contains 'ALL' value.
    This approach can impact the performance of the planning application. It depends on the number of data records you are dealing with. Standard Copy and Delete functions are pretty fast in nature.
    I hope it will help you. please let me know if you need more inputs.
    Regards
    Tarun

  • How to select 10 random records?

    Requirement is:
    Show all records if query returns less than equal to 10 records.
    Else
    Show random 10 records.
    How do I achieve that using SQL alone?
    Tried with sample but that didn't work. The number of records in table continuously growing.
    Thanks

    Hi,
    would tell me how it works. little bit confusing me..
    SQL> select count(*) from scott.emp;
      COUNT(*)
            14
      1* SELECT *   FROM scott.emp SAMPLE (8)
    SQL> /
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO EMAIL
          7839 KING       PRESIDENT            17-NOV-81       5200       8250         10
    SQL>
    SQL> ED
    Wrote file afiedt.buf
      1* SELECT *   FROM scott.emp SAMPLE (7.5)
    SQL> /
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO EMAIL
          7788 SCOTT      ANALYST         7566 09-DEC-82       3200        450         20
          7934 MILLER     CLERK           7782 23-JAN-82       1500        195         10
    SQL> SELECT *   FROM scott.emp SAMPLE (7.5);
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO EMAIL
          7902 FORD       ANALYST         7566 03-DEC-81       3200        450         20Edited by: Ravi291283 on Jul 27, 2009 2:32 AM

  • How to fill an empty cell with the value above

    Hello,
    Please help me on the following issue related to BEx query and it's output in BEx analyzer as well as on Web.
    I am trying to modify a query output where the empty cells are to be filled with the value in the above cell.
    e.g. there is a column for transaction number, and this transaction number is the same for three rows, so it turns out to be two empty cells and only appears as if the transaction number applies to the first row only.
    not sure how to paste screenshot or attach document but would love to provide more information if the above isn't suffice.
    Please advise on what and where to modify in BEx designer.
    Thank you for your help!

    Thanks a lot...yes, now it works in BEx Analyzer but for some reason doesn't work in the Web view.
    Any ideas why is that?
    Thanks again for your prompt help.
    Edited by: One Idea on Jan 15, 2009 12:17 AM

  • How to select, with a SUD DIALOG, the range and the trace data to import from citadel

    Hello,
    I use DIAdem to generate reports from Citadel and I would like to create a script which asks the user to select data and it's corresponding range to import it from citadel. The script should display a dialog box (sud dialog), the user will choose the data and the range. 
    I would like to know if a function exists because up to now, I have not found anything suitable for this.
    In my search i found this (see answer from Brad Turpin) http://forums.ni.com/ni/board/message?board.id=60&message.id=985&requireLogin=False
    But I don't know how to automatize it with sud dialog
    I am looking for information and examples on the subject.
    Thanks

    Hello,
    I changed the data base path, when I run the script an error message appeared (see attached file). When I look the dataportal files, I see that the complet data is charge and not a window (see attached file). have you any idee?
    Attachments:
    error load citadel function.pdf ‏455 KB
    view.pdf ‏279 KB

  • How to select Vendor information as per the line item of the shopping cart

    SRM ABAPers,
    I want to create a custom report and needs to produce SC's item details with vendor's information.
    So I want to select the vendor information(including the partner function- 00000019 or 00000039) as per the line item of the shopping cart, which SRM table can give me this information?
    Thank you!
    MP

    Hi,
    To get the SC item details,you an use the FM 'BBP_PD_SC_GETDETAIL".
    Also to get the vendor details,you can use the FM "BBP_PARTNER_GET_PURCH_DATA_NEW".
    BR,
    Disha.
    Pls reward points for useful answers.

Maybe you are looking for

  • Newbie Can I have an "IF Statement" in a WHERE clause?

    Example Select T.name,T.District,T.Dept from table T where IF myUnit=9998 THEN T.District='OZ' ELSIF myUnit=9997 THEN T.District='DE' ELSE T.Dept=myUnit END IF; ( myUnit is a variable selected by the user) TIA Steve

  • My iTunes Match won't load past step 1; All songs in my library say "Exceeded Limit", even the ones that were uploaded before.

    My iTunes Match hasn't been working for a couple of days. It said I had exceeded the song limit, so I was going through my library and clearing out some songs. When I deleted the songs, the box that asked if I wanted to delete them from the cloud was

  • OBYA Settings for Intercompany Customers and Vendors

    Hi SAP folks, I have a small question on TC: OBYA We have 2 co codes (CC10 & CC20) . We have customer and vendor account with the same number 900CC10 in Co Code CC20 and  customer and vendor account with the same number 900CC20 in Co Code CC10 The re

  • Unable to make in game purchase

    Hi, I just updated my credit card details under my account. And I tried to make in game item purchase, but they are asking me to "please contact iTunes support to complete this transaction". May I know how do I overcome this message? My country iTune

  • Anyone facing lag on OS X Mavericks ?

    I am using Macbook Pro 13" Core i7 (2012 model) and had just updated to OS X Mavericks. Its a great new OS X and i love the new features, however, i have problem of being lag throughout the system :O Especially when scrolling on launchpad. Anyone fac