Jump to content
Xtreme .Net Talk

feurich

Avatar/Signature
  • Posts

    175
  • Joined

  • Last visited

About feurich

  • Birthday 02/24/1966

Personal Information

  • Occupation
    Technical consultant
  • Visual Studio .NET Version
    Visual studio Professional
  • .NET Preferred Language
    C#

Contact Details

  • Skype
    efeurich

feurich's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Ok, so i see that I have to do something with the paint event. But when I put the setdialog dimensions in this paint event it loops for ever. How do I just run the paint event one time? Cire
  2. Hi there, I am struggling with the following for some time now. I use the datagrid control in 3 ways. 1. To view a database query result and search in the result in the datagrid 2. When I need to update the database with a record 3. When I Insert data into a record. Depending on these three functions I need the datagrid to behave different. In the case of 1. The first row should be editable and the rows containing data should be read only. Just for selection purpose In the case of 2. Only the row that needs to be updated (record in the database) should be editable. Just add a complete row from the datagrid view as a ercord in the database. In case of 3. the row where the insertion needs to be done should be editable and the rest read only. Insert the new data in a existing database record. What is the best way to do this? is it better to do this ina custo control or just code it in the forms? Thanks in advanced, Cire
  3. Hi there, This is puzzling me for some time now. In the old days when I was writing code in VB6 the version information and build info was automatically inserted in the new dll that you build. But now in C# when I build a dll with tlb file(COM) the same version is visible in the properties of the dll. My question now is how can I get the major, minor and build information in the dll. So every time I build the dll a new build is generated. Thanks, Cire
  4. Hi, This is a piece of the code. /// <summary> /// Initializes a new instance of the <see cref="DatabaseDialogForm"/> class. /// </summary> /// <param name="databaseDialog">The database dialog.</param> public DatabaseDialogForm(IDatabaseDialog databaseDialog) { InitializeComponent(); this.databaseDialog = databaseDialog; DataGridView1.DataSource = this.databaseDialog.DataCollection.Tables[0]; this.SetDialogDimensions(); this.Text = databaseDialog.DialogCaption; this.restoreDialogDimensions(); } /// <summary> /// Sets the state of the Database Dialog. The first row should be editable and another color /// the rest of the rows must be readonly and alternating color. /// </summary> private void SetDialogDimensions() { // Place a empty datarow in the DataCollection Tables var dataRow = this.databaseDialog.DataCollection.Tables[0].NewRow(); this.databaseDialog.DataCollection.Tables[0].Rows.InsertAt(dataRow, 0); // Make datagridview not sortable foreach (DataGridViewColumn dgvColumn in this.DataGridView1.Columns) { dgvColumn.SortMode = DataGridViewColumnSortMode.NotSortable; } // Set the first datarow to editable the rest is not! DataGridView1.Rows[0].DefaultCellStyle.BackColor = Color.LightYellow; DataGridView1.Rows[0].ReadOnly = false; // Make the rest of the row readonly. Starting from row 1 for (var i = 1; i < DataGridView1.Rows.Count; i++) { DataGridView1.Rows[i].ReadOnly = true; } DataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.Honeydew; DataGridView1.Refresh(); }
  5. Hi There, I have a datagridview control that I do the following to. I load a dataset with data from a SQL database then I add an empty datarow as the first row. This empty row i will use for unputting the search text when the datagridview is in runtime. So you can search the database from within the datagridview if the first result isn't what you want. Now the first row needs to be editable but the rest of the rows need to be read only. This is working but only after I performed a search in the empty row. It looks like when the control is first initialized the SetDialogDimensions sub(I have created which sets the dimensions for the dialog) isn't performed. I have already tried Datagridview.Update en refresh but this doesn't work. Is there any other event i can trigger to make the SetDialogDimensions work? Thanks, feurich
  6. Found it! You can access the selectedRowIndex with the following: DataGridView1.CurrentRow.Index Sometimes it is so simple :D Sometimes you look for something that is right in front of your nose. Thanks for the patience. hciruef
  7. Hi There, Is there a way af determining which row is selected in the DataGridView_KeyDown event? I need to know this because the first row is a search row and the other rows are display rows. So if the user want to search he/she adds information in the first row and hits enter to search the database. OK, Hope this is clear enough.
  8. Maybe i am misunderstanding you but this could be a solution. You could programmatically fill a dataset with the country values and id's and afterwards you can bind this dataset to the combobox. In this way you can first set the datasource property of the combobox and bind the dataset afterwards. Hope it helps!!
  9. Hi There, It's not the DataGridView1.SelectedRows[0] property that was needed but the DataGridView1.Rows[0].Cells.Count. That solved this problem on the the next one. Thanks PlausiblyDamp for showing the way.. :) // Only take the first row for the search values string[] cellValues = new string[DataGridView1.Rows[0].Cells.Count]; for (int i = 0; i < this.DataGridView1.Rows[0].Cells.Count; i++) { cellValues[i] = DataGridView1.Rows[0].Cells[i].Value.ToString(); }
  10. Hi There, It's not the DataGridView1.SelectedRows[0] property that was needed but the DataGridView1.Rows[0].Cells.Count. That solved this problem on the the next one. Thanks PlausiblyDamp for showing the way.. :)
  11. The problem here is that i get an error on the SelectedRows[0].Cells.Count part of the statement. It says: System.ArgumentoutOfRangeException in the for loop. Actual value was null. But I am in the grid and there are 3 cells filled with data in the first row...
  12. I have this....!! :confused: int i = 0; string[] cellValues = null; // Only take the first row for the search values foreach (DataGridViewCell dataCell in DataGridView1.SelectedRows[0].Cells) { cellValues[i] = dataCell.Value.ToString(); i++; }
  13. Hi there, I need to store all the values of the first row of a datagridview in to an array. I have tried a lot but havent managed to do this. Can someone help me on the way. Thanks,
  14. DataTable dbTable = new DataTable(); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(cmdString,connString); // Add empty Row to dataTable DataRow dataRow; dataRow = dbTable.NewRow(); dbTable.Rows.InsertAt(dataRow, 0); sqlDataAdapter.Fill(dbTable); dataGridView1.DataSource = dbTable;
  15. I tried to do so but I get the message "Rows cannot programmatically be added to the Datagridview's rows collection when the control is data-bound". The DataGridView control is bound to a DataTable and after that I am trying to add the row. Is this possible I ask myself and DPrometheus ? :confused:
×
×
  • Create New...