Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Inhalt einer Zelle aus einem DataTabel in einer TextBox ausgeben

Empfohlene Antworten

Veröffentlicht

Hallo Freaks!!

Ich sizte zur zeit an einem Oracel-Client. Dieser bekommt über eine Textbox ein Sql-String übergeben. Dieser wird abgesendet und die Ergebnisse werden in einnem DataGrid angezeigt. Das funkt auch schon ganz gut. Da der Inhalt einer Zelle einer Tabell sehr groß sein kann und das DataGrid bei zu vielen Daten wohl möglich das ****en anfängt, versuche ich jetzt den Inhalt der Zelle in einer seperaten Form mit Textbox anzeigen zu lassen. Ich bin mitlerweile so weit, das die Form aufspringt sobald ich auf eine der Zellen im DataGrid klicke. Mein Problem liegt nun darin, wie ich den Inhalt der Zelle in die Textbox gekomme. Kann ich diese Info aus dem DataTabel ziehen oder muss ich noch zusätzlich ein seperaten Sql-String absetzen welcher sich direckt auf die angewählte Zelle bezieht!

Ich muss dazu sagen, dass ich erst 3 Woch dabei bin und fals ich irgendwas falschen sage bitte gleich sagen :(

Hier noch ein paar Codefetzen:


[C#]

//Connection, Abfrage und Visualisierung im DataGrid

private void Find()

    {

      dataGrid1.DataSource = null;

      OracalConnection conn = new OracleConnection(connstring);

      conn.Open();

      string sql = rtb.Text;

      OracleDataAdapter adapter = new OracleDataAdapter(sql,conn);

      adapter.Fill(dt);


     DataView view = new DataView(dt);

     dataGrid1.DataSource = view;

    }




//Feststellen der Positon im DataGrid und öffenn der TextBox

private void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)

    {

      //dataGrid1.HitTest(

      Form3 form = new Form3();

      System.Drawing.Point point = new Point(e.X, e.Y); 

      DataGrid.HitTestInfo hit = dataGrid1.HitTest(point); 

      if(hit.Type == DataGrid.HitTestType.Cell) 


      { 

        dataGrid1.CurrentCell = new DataGridCell(hit.Row, hit.Column); 

        dataGrid1.Select(hit.Row);

        form.ShowDialog(this);


      } 

    }

dataRowView = dataView[dataGrid.CurrentRowIndex];
Das übergibst Du an deine andere Form und in der schreibst Du dann:
textBox1.Text = drv["XXX"].ToString();

Ansonsten kannste Dir auch mal DataBinding anschauen, falls alles auf einer Form liegt ist es sehr einfach.

Ich hab das Problem jetzt so gelöst:

Trotzdem vielen Dank für die Hilfe!!!!

 private void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)

    {


      Form3 form = new Form3();

      System.Drawing.Point point = new Point(e.X, e.Y); 

      DataGrid.HitTestInfo hit = dataGrid1.HitTest(point);

      if(hit.Type == DataGrid.HitTestType.Cell ) 

      { 

        dataGrid1.CurrentCell = new DataGridCell(hit.Row, hit.Column); 


        string text = (string)dt.Rows[hit.Row][hit.Column];

        dataGrid1.Select(hit.Row);

        if (text.Length > 20)

        {

          form.richTextBox1.Text = text;

          form.ShowDialog(this);

        }

      }

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.