Ahmet Tanakol
Ahmet Tanakol

Reputation: 899

Infragistics.Win.UltraWinGrid.DoubleClickCellEvent c#

I was working on a project and I need to read a row in a Infragistics GridList when I clicked twice on the row.This is how I filled my girdlist

     try
        {
            if (txtAd.Text.Replace("'", "").Trim() == string.Empty && txtSoyad.Text.Replace("'", "").Trim() == string.Empty)
            {
                stBarMsg.Text = "ad soyad girilmeli!";
                return;
            }

            DataTable dt = PrePaidLib.getParaPuanGoruntulemeList(true, txtAd.Text.Replace("'", ""), txtSoyad.Text.Replace("'", ""));
            grdList.DataSource = dt;
            grdList.DataBind();
        }
        catch (Exception exp)
        {
            ErrorLib.ErrorHandle(exp, "frmParaPuanGoruntuleme.retrieveRecord");
        }

Here, you can find my double click function

        private void grdList_DoubleClickCell(object sender, Infragistics.Win.UltraWinGrid.DoubleClickCellEventArgs e)
    {
        try
        {
            txtKartno.Text = grdList.Selected.Columns[0].ToString();//Cells[1].ToString();
        }
        catch(Exception ex)
        {
            ErrorLib.ErrorHandle(ex, "grdList_DoubleClickCell");
        }
    }

This line doesn't work "txtKartno.Text = grdList.Selected.Columns[0].ToString();" By the way I want to get values for each attribute 1 by 1. I have 4 columns in my gridlist. Any suggestions?

Upvotes: 1

Views: 4074

Answers (1)

Steve
Steve

Reputation: 216313

When you double click a cell in an Infragistics UltraWinGrid, you receive the cell clicked in the DoubleClickCellEventArgs.Cell property. From this property you can reach the current Row using the e.Cell.Row syntax and from that row you can reach any other cell using the e.Cell.Row.Cells[columnName or columnIndex].Value syntax.

So the data you need could be read in this way

txtKartno.Text = e.Cell.Row.Cells[0].Value.ToString();

(I'm assuming the cell required is not the one clicked and the column is at index zero)

Of course if, the clicked cell is the one you need, the syntax is more concise

txtKartno.Text = e.Cell.Value.ToString();

To complete the answer, please note, the UltraGridRow has two methods that can be used to retrieve a cell value from a row:

string textResult = e.Cell.Row.GetCellText(e.Row.Band.Columns[0]);
object objResult = e.Cell.Row.GetCellValue(e.Row.Band.Columns[1]);

According to Infragistics, these two methods avoid the creation of unneeded cells object and therefore are more performant. In your case, it's not clear if these methods are really beneficial.

Upvotes: 2

Related Questions