Here is the UI of my application. It contains a DataSet, a Save Button, a calendar (monthCalendar), and a DataGridView (columns are Assignment, Description, Date Due, Subject Finished). I want it to do the events:
The Calendar changes the dates to a different color if they are in the date due column
The save button should save the DataSet as an XML file in #"\\Assignments.xml" (that is the application folder right? And not C:\Assignments.xml?)
The row should turn a color if the assignment is finished
I'm sorry it is so much. But my application is complex and I just need these events to finish it. Whoever answers the best will be put in the README.txt file for helping me with the code.
Can't you use a bindingsource, and bind the textbox and the description column to the same field?
For changing Calendar (datetimepicker I suppose?) date, you can add a handler for the Validated event, do a check and update the color in the handler.
To serialize the dataset to XML, you may create a class with all the fields in the data set and parse the data into the object then serialize.
Last one, not sure if you want to do this on load or dynamically or what, but I think you can add a handler for the RowValidated event, and do a check on the finished field and then set the color.
Related
I have a datagridview which displays data from database. I have added a a textbox as a searchbox and added a text changed event. In that event I have written Search query with 'LIKE' based on text in textbox. So when I type a character it will instantly search the database and display in datagridview.
But my problem is, for large amount of data, for example a million rows, this text changed event hangs the datagridview. cant display data to datagridview fastly. Any way to speed up the process?
I would use a BackgroundWorker to search my data and handle result only if the box content didn't change in the mean time. I would also add a delay on search to avoid useless search. Actually, when needed this kind of search i prefer handle keydown on Enter or/and a button to be sure that we search when we want to.
I'm working with a XamDataGrid which is bound to a DataTable. When I type in data in the rows and I hit save (to save my data back to the database), it never saves the last row entered. I'm guessing because I need to tab out of the cell that I'm currently entering data in and that it will only move the text to the DataTable upon edit end. Is there a way to copy data to the DataTable as the user enters it so they don't have to tab out to force the edit end or is there a better way? Thanks!
I would add this as comment but am unable to. Its hard to say without more information but have you tried adding UpdateSourceTrigger=PropertyChanged?
"{Binding Path=Something, UpdateSourceTrigger=PropertyChanged}"
The grid should update its source if it loses focus which may not be happening especially if your save button is in a toolbar that doesn't take focus. If that is the case, you can force the grid to end editing and commit the record by calling ExecuteCommand on the XamDataGrid and passing in the DataPresenterCommands.EndEditModeAndCommitRecord command.
I have a gridview with empty cells. Whenever a cell is clicked I replace the contents of the cell (innerHTML property) with a string, using javascript.
I would like to save this changes on a 2d array when the index of my combobox is changed. However when I traverse the gridview during my selectedindexchanged event, none of the changes I did to the cells are visible (all the cells are empty). I guess the changes are not persistent.
How could I do this?
No, the changes are not persistent. You should do some reading about how forms on the web work--not just specific to asp.net--to get a fuller understanding. Basically, your SelectedIndexChanged event is really a POST of a form on your page. Only form values, like those in <input> or <select> fields will be sent to the server and be available to process in your C# code. So, one option would be to have a hidden input for every cell in your GridView. Another one would be to have a single hidden input which stores a string representation of a 2d array, and you would manipulate that with JavaScript every time you change the contents of a cell. Then, when you process this data in your C# code, you'll need to process the hidden inputs, not the cells of the GridView.
I want to make a single event that will capture every change in the data in a DataGridView. The list of events is pretty long. I was thinking I could bind the DataGridView to a DataTable since it has less events and it gets notified whenever the user changes the data in the DataGridView. Since the amount of data is tiny (2 columns and about 5 rows) but the user should be able to add, remove and edit rows, it would be a lot simpler if I put all possible changes in a single event so every other class that needs it gets notified when anything changes in the DataGridView's data by handing a single event. I don't want to capture when the user is typing in a cell or when a row is resized or anything that won't be normally considered as representing a change in the data. That's also why I think using a binded DataTable is a good idea. So my question is, which set of events is the minimum I need to handle in order to capture every possible change in the data contained in a DataGridView or in a DataTable (preferably a DataTable I think)?
I would try to bind to the following DataTable events:
RowDeleted
RowChanged
Those should give you what you want - notification only in case you edit, delete or add a row.
I've got a datagridview that is hooked up to a bindingsource on my main form. One of the columns and datamembers in the bindingsource is a DateTime object. When the datagridview shows this item it doesn't use Window's default region settings for displaying datetime.
The weird thing is, I can access this same DateTime object and print it to a text box, or even pass it off to another form with another datagridview and binding source and it actually shows up properly in that table.
So then, why does the datagridview on my main form not use the regional date/time settings when converting the DateTime object to a string?
I've checked that there was no special formatting applied to the datagridview and so I'm running out of ideas to check.
Do you guys know if there is any super secret way to get a datagridview to follow system regional format rules or not?
Also, since I highly doubt that I did something different with this datagridview vs the others in my application, the next potential area for issue could be on application load: Perhaps since this comes up when the application loads, it's not getting the same cultureUI settings as the other datagridviews?
Update I've tried adding another column to the datagrid view and hooking it up to the same data property (datetime) and I get the same result. So something about how entire datagridview, or how it was created is stopping the "ToString" from using the default regional settings.
Any Help?
On design, in the Edit Columns dialog of the DataGridView:
Search for property DefaultCellStyle, and open this dialog;
Search for property Format and choose Date format;
Choose your favorite format.