Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've enterd several CSV files into listbox and i've loadded them to a datagridview
but as a begainner i've faced this problems .
1- i want to replace multible selected cells values with one value in textbox
2- i want to save every single file in it's own location not the whole datagrid in one file but every file with it's changes to be saved
that's it
Posted

1 - Here is the code I use to "Fill" the cells that are selected with the same value. I fill with whatever is in the clipboard or whatever was recently copied...but you can change that to your textbox's .Text.
VB
If dgvOutput.SelectedCells.Count <> 0 AndAlso My.Computer.Clipboard.ContainsText Then
   For Each c As DataGridViewCell In dgvOutput.SelectedCells
      'Remove any carriage returns = Chr(10) and line feeds = Chr(13) before pasting into cell
         c.Value = My.Computer.Clipboard.GetText.Replace(Chr(10), String.Empty).Replace(Chr(13), String.Empty)
   Next
End If


2 - The solution to this depends on how you have your project setup. Do you have just one grid and every time the user changes the listbox you load the grid with that file's data? If so, how are you keeping the changes in memory? For example, if I look at file A and make a change, then look at file B...where is the information that is still tracking my change to file A? Or maybe I'm missing your question on this. What specifically are you having trouble with in saving the files?
 
Share this answer
 
thanks man really i appreciate your help ,
actually i've used this code to replace the selected values


VB
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
    For Each cell As DataGridViewCell In DataGridView1.SelectedCells

        DataGridView1.Rows(cell.RowIndex).Cells(cell.ColumnIndex).Value = TextBox4.Text


    Next
    MessageBox.Show("Value replaced")
End Sub







the second problem is killing me

actually my project is like this
1- browse for folder and select all the csv files in the folder and sub folders
2- the csv files bathes are listed in the list box
3- selecting the files from listbox and clicking insert the csv file is populated into the datagridview ( so several files are populated into datagridview at once )
4- editing the loaded csv files in the datagridview
5- exporting the datagridview to one csv file

--------------------------------------------- everything is fine with me till here but .......

6- ((( saving the changes to every single csv file in it's own place bye using the file name and bath from the listbox ))) this is my problem now
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900