The project is a refactoring of "Advanced DataGridView with Excel-like auto filter" you can find here: https://adgv.codeplex.com.
The author, also post this as a patch in the project page.
This Enhanced DataGridView components features:
- Ascending or Descending Sort order for any column, by code or run-time
- Filter any column using a Custom Filter, or selecting values from using an Excel-like Filter List view, using also an advanced feature for DateTime types
- Saving and Restoring preset for Filter and Sort
- Enabling or Disabling Filter and/or Sort features for any column,by code or run-time
- Search ToolBar to find values in columns
It is written using Microsoft Visual Studio 2012, using the .NET 4.0 framework.
Copyright (c), 2014 Davide Gironi <davide.gironi@gmail.com>
Original work Copyright (c), 2013 Zuby <zuby@me.com>
This project is licensed under the Microsoft Public License (Ms-PL), see attached LICENSE file for further information.
ChangeLog
- 1.0.x.11: fixed DateTime filter problem
- 1.0.x.10: fixed AdvancedDataGridViewSearchToolBar problem with not Visible column search
- 1.0.x.9: first release
Code
- https://github.com/davidegironi/advanceddatagridview
Binary: AdvancedDataGridView-bin_1.0.19121.10.zipSource: AdvancedDataGridView-src_1.0.19121.10.zipBinary: AdvancedDataGridView-bin_1.0.17202.9.zipSource: AdvancedDataGridView-src_1.0.17202.9.zip
Notes
- read risk disclaimer
- excuse my bad english
Hello
ReplyDeleteDisplaying the project I would like to know if there in VB. I have translated with code translators (Instant for VB from Tangible Solutions) but does not work in especially in the case of filter dates.
I think the problem is in the translation BuildNodes(ByVal vals As IEnumerable(Of DataGridViewCell)) for data type for dates
Sorry for my bad English
Regards from Spain and thanks
Eduardo my mail is e.gomez.lopez@hotmail.com
This project is written in C#, no VB, but you could use it in any VB.NET WinForm project, adding the compiled dll as a reference. I've never try auto-transaltor. You should modify the c# code, instead of translatin it.
DeleteHello,
ReplyDeleteI have a problem. When I filter a column checking "Blanks" value, then I try to reset Filter, but all the data get lost and therse no way to getting back even if i try to repopulate databinding.
Hello,
Deleteunluckly i don't get this issue. Try to tell me step by step how do you get this error. Let's take AdvancedDataGridViewSample as example, if I open this sample program, the i click on the "string" column filter/order icon, then i select only the "(Blanks)" value. I get the blank filtered. Then if i check "(Select All)" or i click "Clean Filter And Sort" button, the filter resets, and the column are all repopulate.
Ho, have you solve this problem??
DeleteThanks for answer Davide. Im gonna try with example and see wath happens. comming back with coments!
ReplyDeleteHow can I implement this in a vb project on an already created and bound DataGridView? I can't get it to work. An example of the code would be nice. Thanks
ReplyDeleteHello, there are at least two ways. One is to remove your old datagridview components form you form, and then add this new grid you have added to your toolbox. Another is just to rewrite the code of the designer to initialize the AdvancedDataGridView. Before starting up to replace the DataGridView of you project, my suggestion is to recreate the sample project "AdvancedDataGridViewSample" in VB, the porting will be easy.
DeleteDavid, this is the best example of what Microsoft SHOULD do, but do not. However, like Colton, I need a better understanding of how to implement this into a project using VB. I have import the dll but no extra datagridview appears in my toolbox.
ReplyDeleteCan you please provide some support code to use your product?
Thank you. Before using this components. You should add this item to the toolbox. Right-click on toolbox - Select "Choose Items" - Browse to your DLL - Add the item.
DeleteThen use this as a normal grid, You just have to attach two handler in order to make it works, the FilterStringChanged and the SortStringChanged, set the BindingSource Sort and Filter property here, take a look at the Sample project. Then there are other thing you can do with this grid, but that's the basic.
hi Davide very good job
Deletein the filteringstringchanged he didnt recognise the zuby from the zuby.adgv.advanceddatagridview
thanks
Hello, tahnk you for this feedback. Please be more specific, I can not understaind where's the missing attach point here.
Deletethanks davide for the reply
Deletei put reference to your dll file and it worked
thanks a lot and again good job
Happy to hear that. Thank you and good work.
DeleteDavide,
ReplyDeleteI've downloaded the source code and tried to load your solution for some testing. Unfortunately, the source doe zip file you provided seems to have a problem. When I load it in VS 2012 or 2013 the code runs fine but trying to open the AdvancedDataGridViewSearchToolBar and AdvancedDataGridView components just come up blank on the design surface. What am I missing?
Thanks,
Stephen
Hello, I've imported it to VS2013, and rebuild the project. No problem at all here. It happens even if you drag and drop a new AdvancedDataGridView from the toolbox to the FormMain of the sample project?
DeleteNo, I can use the ADGV control with out problems but what doesn't seem to be working for me is opening the Advanced DataGridView CS project and trying to view the AdvancedDataGridView.cs control on the designer surface.
ReplyDeleteThe AdvancedDataGridView class in an extention to the DataGridView, then, it will not be painted by the visual studio designer as an editable component. Sorry about that.
Delete@Davide Thanks for example actually i am working on similar approach i am pass the the data table for grid view
ReplyDeleteDataTable dataobj = new DataTable();
dataobj.Load(rdr); // some query and it have some data in it
advancedDataGridView_main.DataSource = dataobj; // pass to your grid view component my data table
and filter function of excel ( kind of throwing some exception )
can you help me out
my showing some example
passing the datatable for gridview ?
Hello and thank you for your feedback. If you look at the FormMain constructor in the FormMain class of the AdvancedDataGridViewSample
Deleteproject, you could see how i load the AdvancedDataGridView DataSource.
Davide, I really need some help. I am populating the ADGV with database query. No can you give the population of ADGV with some database example.
ReplyDeleteAfter I load the ADGV with SQL Query, the ADGV load the data properly and shows the filters as well. But I am not able to populate the datasource back while filtering. Can you explain completely with one example.
My Source code is like below
public void loadGrid()
{
sql = "Select * from tbl_IdDetails";
sql1 = @" SELECT [Branch Code]
,[Server]
,[UserID]
,[NAME]
,[NNFCTCL]
,[NNF CASH]
,[FOCTCL] from tbl_IdDetails";
objFunc.populateGrid(sql1,ADVANCEDDATGRID);
}
private void multiEditDataGridViewPanel1_FilterStringChanged(object sender, EventArgs e)
{
bindingSource_main.Filter = ADVANCEDDATGRID.FilterString;
}
I am not able to pass the data source back while filtering. Please help with an complete example. Thanks for your help.
You can set you datagrid DataSource to your BindingSource, then you could load you BindingSource.DataSource with a DataTable loaded with the database rows.
DeleteDavide, Thanks for your reply. I tried but not able to figure it out. I am very new to dot net and Not able to manipulate much. Can you please give a complete example with full code??? A complete code with database connectivity?
DeleteThanks very much for your help in advance.
I'm sorry but I usually does not provide complete examples on request, because if I do this for you, I have to do this for any asking this, and I have not time to do this for any request. Really sorry.
DeleteI can just poin you to the solution. First step: have you done this with a standard DataGridView?
Yes, I did this with a standard DataGridView. After that the filter is applied on them. The data with filter is coming properly. But when I use the filter, datagrid does not refresh with the filter.
DeletePlease let me know how to set the filter with filter string. just that line of code.
Ok, let's do it at steps. Use an AdvancedDataGridView, with the attached FilterStringChanged method. Add a debug point on you set filter function (i mean here in your example above: bindingSource_main.Filter = ADVANCEDDATGRID.FilterString;) the when you trigger a filter event (as exemple by setting a custom filter), take a look to the "FilterString". Does it contains the proper filter string for the BindingSource?
DeleteUsing the AdvanceDataGridView Control. This is the below complete control on load of the page and then on filter string. It is giving error that filter string is null
Deletepublic IdDetails()
{
InitializeComponent();
_dataTable = new DataTable();
_dataSet = new DataSet();
//initialize bindingsource
bindingSource_main.DataSource = _dataSet;
//initialize datagridview
multiEditDataGridViewPanel1.DataSource = bindingSource_main;
//set bindingsource
}
public void loadGrid()
{
sql = "Select * from tbl_IdDetails";
sql1 = @" SELECT [Branch Code]
,[Server]
,[UserID]
,[NAME]
,[NNFCTCL]
,[NNF CASH]
,[FOCTCL] from tbl_IdDetails";
objFunc.populateGrid(sql, multiEditDataGridViewPanel2);
objFunc.populateGrid(sql1, multiEditDataGridViewPanel1);
objFunc.DatatableData(sql1, _dataTable);
multiEditDataGridViewPanel2.Columns[3].Frozen = true;
}
private void multiEditDataGridViewPanel1_FilterStringChanged(object sender, EventArgs e)
{
bindingSource_main.Filter = multiEditDataGridViewPanel1.FilterString;
}
private void IdDetails_Load(object sender, EventArgs e)
{
loadGrid();
objFunc.InitializeEditableDataGridView(multiEditDataGridViewPanel2);
}
Hello, please do not flow with comments of code here. Instead build a little project sample. Do not load data with a dabatase but just create sample data. Then, when you've got this, share the solution link one can download to test. From what i see it could be the populateGrid function. If the FilterString is null, something goes wrong in the filter creation procedure. You can see it debugging the code from the advanceddatagrid.
DeleteHello, how can I make this sln file work with my VS 2008? It is a requirement of me to use VS 2008 at the moment, so can't change to newer editions.
ReplyDeleteYou can create a new solution, new project and import files. Or you can try to edit by hand the csproj/vbproj files setting "Microsoft Visual Studio Solution File, Format Version" to 10.00 (which is Visual Studio 2008), but I'm not shure it will works.
DeleteThis comment has been removed by the author.
DeleteThank you for the input. It already is set to 10.00, unfortunately. If theoretically I build this from a newer edition of VS 2008 and get the dll and include it to my references, how would I use it in my project? Is it a completely new control type which I must substitute in place of the normal datagridview?
DeleteIt's an extention of the DataGridView, you can build with other VisualStudio as long as you are using .NET 4.
DeleteI'm trying to use it, but I can't see how to set BindinSource DataSource with dataSet, like the sample. There's no step by step to use this component, so it's not very helpful. :(
ReplyDeleteAlso, if I don't populate the grid with DataTable (I'm currently using AddRows), is it possible to still make ADGV work?
Thanks!
Hello, you just have to use attach the Bindisource like you usually do on DataGridView. Looking at the sample provided, the line "advancedDataGridView_main.DataSource = bindingSource_main;".
DeleteRight. I've got it. The only problem now is that I don't know how to pass a list of DataGridViewRow to the BindingSource DataSource, because by doing this I see all DataGridViewRow class members instead of Cells content only. This code doesn't seem to work:
DeletebindingSource.DataSource = dgvRowsList;
bindingSource.DataMember = "Cells";
datagrid.DataSource = bindingSource;
Any idea?
Thanks once again :)
You could load a typed IEnumerable (let's say for example you have a class Person, you will load a IEnumerable enumberablePerson = ...), then convert it to a DataTable and load it as your BindingSource.DataSource by using something like this: yourBindingSource.DataSource = DGDataTableUtils.ToDataTable(enumberablePerson);
DeleteYou can find the ToDataTable here: https://gist.github.com/davidegironi/9348c74c01d979942901#file-dgdatatableutils-cs
Also remember to set the DateGridView.DataSource to the BindingSource, like you are doing: yourDataGridView.DataSource = yourBindingSource
Hmmm... For architecture reasons I'm trying to avoid DataTables. :(
DeleteThis comment has been removed by the author.
ReplyDeleteHi David - new to your site - have downloaded the dll and added to both references and to the toolbox in VS2013. Bound datasources for 2 applications - one VB net and the other is in C# -- both access and load the data, but alas the autofiltering function and sorting both don't respond. The complete dataset remains displayed as initially loaded. Any ideas? =Vytas A
ReplyDeleteHello. Have you FilterStringChanged and SortStringChanged EventHandler to you AdvancedDataGridView instance? Take a look to the FormMain from the provided sample as reference.
DeleteI am unable to add the DLL in tool box in VS2015. Please let me know if I need to do anything specific to make it compatible with VS2015
ReplyDeleteHello, Does the sample project provided with code get imported and runned?
DeleteThis comment has been removed by the author.
ReplyDeleteyour project is really good, thank u, one problem that i have is, i want to enable only one column sort like excel. if i sort a second column the old sort filter in the other column should be cleared like that of excel. is there any way to do this?? Thank you..
ReplyDeleteYou have to modifiy the code. You could change the MenuStrip.SortChanged event in order to CleanSort just for the not selected columns.
Deletehi,thank u for replying,i added an else{cleansort} for cell_sortchanged its giving the desired result,but the ascending and descending image don't change..any ideas
ReplyDeleteImages changes on sortASCMenuItem_Click and sortDESCMenuItem_Click methods, add a debug point there, see what's happenen...
Deleteok, i will,is there anyway to disable custom sort and enable the default datagridview sort??
DeleteThank You
Not by default. MenuStrip is the key again for this.
DeleteHi Davide,
ReplyDeleteDuring a small project I am working on I found your remake of the ADGV Dataview.
I am having a small issue and was hoping you can help me a bit.
I’ve setup a DataBinding to an SQL server and the information is showing correct. However the filter and sort isn’t working.
I found you posted this on your blog:
just have to attach two handler in order to make it works, the FilterStringChanged and the SortStringChanged, set the BindingSource Sort and Filter property here, take a look at the Sample project. Then there are other thing you can do with this grid, but that's the basic.
I can’t open the Sample project in 2015 and I am pretty new to programming so I was hoping you can help me a bit. Can you explain a bit what I need to do to get it working?
Thank you!
Mike
Hello,
DeleteThis sample project was built in VS2012.
VS2015 should be able to import the VS2012 project. I'm using VS2013 and VS2015 for other projects, and never encounter problems on opening VS2012 solutions with VS2013 or VS2015.
What's the problem VS give you on opening the VS2012 solution?
Anyway that's right, you just have to attach the Filter and Sort events.
Hello Davide. Good stuff here :)
ReplyDeleteHowever the current date filtering wasn't working for me with a en-US culture.
Long story short, here's a fix that should work across all cultures when it comes to the date formatting used in the controls current date filtering.
The 2 files to modify are FormCustomFilter.cs and MenuStrip.cs.
In MenuStrip on line 67-68 change const to readonly;
private const string ConvertYearMonthDayFormat = "dd/MM/yyyy";
private const string ConvertYearMonthDayHourMinuteSecondFormat = "dd/MM/yyyy HH:mm:ss";
to
private readonly string ConvertYearMonthDayFormat = dd/MM/yyyy";
private readonly string onvertYearMonthDayHourMinuteSecondFormat = "dd/MM/yyyy HH:mm:ss";
Then go to line 88 in the constructor and insert the following;
ConvertYearMonthDayFormat = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
ConvertYearMonthDayHourMinuteSecondFormat = ConvertYearMonthDayFormat + " " + CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern;
Just do the same thing to FormCustomFilter.cs.
There may be a reason not to use these changes, but it's working for me in both my test cases.
But anyways, good stuff :)
Hello and thank you for your feedback!
DeleteCan you try this version? http://wikisend.com/download/436394/AdvancedDataGridView-src_1.0.19617.11.zip
I think I've fixed it for multi-cultures. I've checked it overriding the program culture by the code you find in sample Program.cs and it seems to me to work. Before posting it i just need your checking feedback. Thank you.
Note: link expires in 14 days.
DeleteOk, I have it. I'll be able to check it in a couple hours.
DeleteOk, that seems to have fixed it Davide. Good job.
DeleteYup, I'd release that version. It's pretty important :)
On a side note. I have a bug fix/check (dealing with Image columns) and a new feature (dealing with the filtering) that I'm working on. I was thinking of publishing your source to BitBucket. If you don't have any objections that is. I can make you lead on it of course lol. This way others can issue Pull requests when they make good changes to thier own version.
Up to you man. I'm gonna publish it anyways because I like source control hehe. But, I'll make it a private repo without your blessing.
Hello, thank you for your feedback. Yes, it's time to move this project to a CVS. I'm using bitbucket for my private repository, and GitHub for public. You can find the code on the GitHub link above. Hope it's not a problem for you GitHub instead of BitBucket.
DeleteAbsolutely not man. I use GitHub too :)
DeleteCool.
David, could You upload egain your fixed Advenced DGV? I will be very greatfull for that :)
DeleteHello, you can find the last version of this project (the fixed 1.0.*.11 one) in the gitub page, there you can also find the compiled release. I've to take time to test and merge the Earl pull, I hope to have time next week.
DeleteGreat job man, very very helpfull!
DeleteUnfotunetly Your ADGV doesn't support a column type of 'Time'. I work on hh:mm:ss format and this is the same problem like before with dates. David, could You help me with that or give me some advice how to manage this problem?
DeleteHi David,
DeleteThanks for providing this useful stuff.
I have one problem with date time calendar control with Advance datagridview.
After binding it make that calendar control column readonly(not editable).
Can you please help in that?
Hello Bartosz, please check the new release, it should even work with TimeSpan.
DeleteHello Brinda, I've checked it, but to me it seems to works. Can you packup a sample?
DeleteHi there David, I was searching for something exactly like this for a project of mine and this seems like this will do the trick.
ReplyDeleteI have a question for you though, the data gridview, lets say I added some data into the table which is displayed in the gridview from another form and when I open the form where the filter functionality is located, will the gridview show the updated/newly added values or not?
I am asking this because currently i am not able to access my pc
that is used for development.
Hello, the databinding of this component works exactly like the Microsoft winform datagridview, so if you set the Datasource of this grid to a BindingSource DataSource, if you take a look to the sample provided code, you will notice that the DataSource of this component it is set to a BindingSource before the binding source is loaded, then when it is loaded by the SetTestData method, the table is populated.
DeleteOk so I found out that the data/table is generated from here I guess.
Delete//initialize bindingsource
bindingSource_main.DataSource = _dataSet;
//initialize datagridview
advancedDataGridView_main.DataSource = bindingSource_main;
//set bindingsource
SetTestData();
so what should I add here if I want to add my own data table instead of the one used in the sample
You just have to set DataSource to your _dataSet, then load this with SetTestData
DeleteCould you tell me what changes I need to main in the FormMain so that My table is displayed rather than the one that is already being used
ReplyDeleteHello. To load the Main table would not be so difficult, but i think you have to understand why does it works that way. The best thing you can do is to follow some tutorial on .NET bindingsource tutorial.
DeleteHi David,
ReplyDeleteThanks for providing this useful stuff.
I have one problem with date time calendar control with Advance datagridview.
After binding it make that calendar control column readonly(not editable).
Can you please help in that?
Hello, do you mean that all the cells of a datetime column are readonly, and column of other type, like string, has cells that be edited?
DeleteYes actually I am using calendar control data grid view column in it.
DeleteBut figure out the solution I have to manually set that column property read only true and than its working fine.
Want to take your guidance on another thing as well. If I use this grid for 8-10 columns its loading is pretty much fast 1-5 sec but when working with 100 columns its taking 40 secs which is bit more.
Can you focus on that part of optimization?
For that amount of column you can disable the sorting andor filtering for all the column that you do not use. Or, if you want, you can try the optimization on the code on github, then do a push.
DeleteIs there an option of numeric sort? TIA.
ReplyDeleteHello, yes, it's the sort icon on each column header. So if the underline column has a numeric datatype it will be sorted by numeric order.
DeleteHi Davide Gironi,
ReplyDeleteI am using your datagridview and it is fantastic!!! I get data from database and bind to your advancedgridview and the filters are brilliant.
There is a functionality in the app to get the latest data on pressing F5. When i remove the datasource and rebind with the new data, the filters are lost.
Is there a way to retain the filters with refreshing of data. Please let me know asap. Thanks in advance.
Hello, thank you for your feedback. Filter and sorting does not change even if you reload the attached BindingSource. And there's a save and restore filter and sort function.
DeleteThanks for your response. Can u pls send me a sample code for that? Thanks.
DeleteThis comment has been removed by the author.
DeleteThis is how it works to me, without any change.
DeleteI did change the code as below:
DeletebdSharepointSource.DataSource = dtSharepoint
bdSharepointSource.ResetBindings(False)
I am updating datatable dtSharepoint and reassigning to binding source and calling resetbindings.
It is working as expected. I could see the changes coming in. But when i click on clear filter of any one column, all filters are getting cleared. Can you please check whether this issue is there in your code and let me know? Thanks again for your help.
Staring from the project sample. Add a Reload button that perform
Delete_dataTable.Rows.Clear();
AddTestData();
In the sample, that way filters and sort does not change.
It worked. Thanks a lot for your help and timely help.
DeleteHello, happy to hear this ;)
DeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteFor an instance, I opened the filter menustrip by clicking the filter button. The filter menu is now open. If I want to close the filter menu, either I have to click on 'Cancel' button or I have to click somewhere else on the datagridview. But we I re-click on the same filter button (of the column which already menustrip is open), the filter menustrip closes and opens again. On this second click, it should only close and should not open again.
ReplyDeleteHello, and thank you for suggestion. I've reply you on GitHub.
DeleteWhere to download more components like this ADGV? I would like to download an advanced listbox, which accepts multiple columns with multiple fields
ReplyDeleteHello, the only other "enhanced" components I've publish can be found here http://davidegironi.blogspot.it/2016/02/enhancedboxhelper-net-winform-component.html it is a TextBox, a ComboBox and a DateTimePicker. Hope this helps.
DeleteHi Davide,
ReplyDeleteGreat component. Awesome Work. Seems my filter is hanging when I change data source. How to I call the clear filter?
Never mind I found it. Silly me. Thanks
DeletebindingSource1.RemoveFilter();
Hello, thank you. Also thank you for posting your solution here.
Deleteprivate void fee_create1_Load(object sender, EventArgs e)
ReplyDelete{
//return to datatabl
this.advancedDataGridView1.DataSource = pardeep.Show_Data("SELECT * from student");
}
private void advancedDataGridView1_SortStringChanged(object sender, EventArgs e)
{
//what code type here to sort advancedDataGridView column
}
private void advancedDataGridView1_FilterStringChanged(object sender, EventArgs e)
{
//what code type here to filter advancedDataGridView column
}
Hello, it depends on what your "Show_Data" method returns. The best things is to attache de DataSource of a BindingSource to a dataset, the the DataSource of the datagridview to the BindingSource generated. You can take a look at the sample file provided in source code, it may help.
DeleteIf we Use sql query to store data in ADGV then what
DeleteHow to sort
Hello, you should link your store to a bindingsource. You could find an example at the dentnet project here: https://github.com/davidegironi/dentned
DeleteIs it possible grouping rows ?
ReplyDeleteHello, no unluckly this is not implemented.
DeleteHi Davide,
ReplyDeleteQuick question relating to loading saved filters.
After loading a saved filter the filter options are locked so the user would not be able to 'extend' the saved filter with additional filter options [post load].
Is there any way, after loading a filter to enable the filter options to remain available to the user for them to further filter the results?
Thanks.
Hello, not using the provided code, a few coding is needed to implement this behaviour. Hope this helps.
DeleteThanks for the super speedy response!
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHello Davide:
ReplyDeleteWhen I was using your filters I would like to know how to update the filter options when the following case happens:
In a status column I have only "new" items. So, it is unable to have different filters options. Once that I update a row with "solved", how could the filter option "load" the new item "solved" automatically? In order to have "new" and "solved" filter options.
I already try:
DeletedataGridView1.LoadFilterAndSort(dataGridView1.FilterString, dataGridView1.SortString);
But, filters, sorts and Icons became gray and disable (gray).
Hello, the LoadFilterAndSort behavior is to disable the filter icon, in order to preload the filters you have to implement your how function or change the code behind the LoadFilterAndSort method. If you do this please share it, it will be usefull it could be something parametric like LoadFilterAndSort(... , bool disableAfterSet).
DeleteHi, greate control how do you implement double buffering, I am using the Dll in a VB project
ReplyDeleteHello and thank you, no the double buffering is not implemented yet, but thank you for suggestion, if you are going to implement that please let me know.
DeleteHi,
ReplyDeletethe only way I have been able to implement double buffering is by following method
Public Sub MakeAdvancedGridViewDoubleBuffered(ByVal dgv As Zuby.ADGV.AdvancedDataGridView)
Dim dgvType As Type = dgv.[GetType]()
Dim pi As PropertyInfo = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance Or BindingFlags.NonPublic)
pi.SetValue(dgv, True, Nothing)
End Sub
Aslo with the searchtoolbar, is is possible that when it finds the data, it brings that row into focus on the grid, reason I ask, is my grid has 10,000 items, the search does find and highlight but would be better if moves grid to found item.
Thank you for your suggestion, I will add a public SetDoubleBuffered() method on the AdvancedDataGridView in the next release. About the list, set _checkTextFilterRemoveNodesOnSearch to true in the MenuStrip class, is that the behaviour you are searching for?
Deleteerrata corrige: to false
DeleteYes that is exactly what I wanted, maybe in next release you could make a setting to enable/disable this feature
DeleteHello, take a look at this version, let me know it everything works like expected: https://expirebox.com/download/0cf9b6140dfc2a01656d9818bedd7903.html SetDoubleBuffered, SetTextFilterRemoveNodesOnSearch and GetTextFilterRemoveNodesOnSearch are added
DeleteYes that seems to be fine, great work
DeleteHi,
ReplyDeleteBTW I am a novide VB coder
I have another question around the search bar
I have the following code:
'initialize dataset
dt = New DataTable
Cursor = Cursors.WaitCursor 'and some various me.Cursor / current.cursor
Application.DoEvents()
Try
Dim ds As New DataSet
Using cnn As New SqlConnection(ConnStr)
cnn.Open()
Using dad As New SqlDataAdapter(strSql, cnn)
dad.SelectCommand.CommandTimeout = 120
dad.Fill(ds, "data")
End Using
cnn.Close()
End Using
If ds.Tables(0).Rows.Count < 1 Then Exit Sub
' Set dataset to datatable
dt = ds.Tables(0)
' initialize bindingsource
BindingSource_Main.DataSource = dt
'initialize datagridview
DataGridView1.SetDoubleBuffered()
DataGridView1.DataSource = BindingSource_Main
'set bindingsource
BindingSource_Main.DataMember = dt.TableName
advancedDataGridViewSearchToolBar_main.SetColumns(DataGridView1.Columns)
When I use the last 2 lines I get datamember'datamember property data cannot be found on datasource
Also my grid has a lot of hidden columns, how do I bind the search to only visible columns.
All help is appreciated.
Hello Paul, for long code sample request, please use pastebin. Anyway, now I can not test this, but I think you can build a new column collection without the coulum you do not need, or just override the attached Search method to skip unwanted columns.
DeleteHi,
ReplyDeleteMe again, I resolved my searches by skipping, I have another question.
I have a hidden column with is true or false, this is represented by an image in a visible column.
How do I set this hidden column to be filtered on a specific value in code, that way I can have a button to enable/disable etc, or if have other columns similar but I want to say filter column a by multiple options.
Thanks
Hello, like you said below, you can use the Filter on Binding Source, there is no way to pragmatically set a column except the LoadFilterAndSort method, but that disable any filters. This could be a nice feature for the future.
DeleteHi
ReplyDeleteThink I have resolved I have just used .filter on the Binding Source
Hi, Do you know why if i use DataboundItem, it always null?
ReplyDeleteHello. What are you using DataboundItem for?
DeleteI want to Move another Form with data in the ADGV. and using advancedDataGridView1.CurrentRow.DataBoundItem as CustomObject. but it said Null, when I Check it has the data, But I can't cast it to the object.. do u have a way to casting this?
DeleteI think you have to custom code the AdvancedDataGridView for that. Sorry about that.
DeleteHi,
ReplyDeletevery nice tool!
Im seaching for the latest BINARY version of AdvancedDataGridView.dll (version 0.1.0.11)
I had a look at https://github.com/davidegironi/advanceddatagridview
but wasn't able to find it.
Could you please give me advice?
Thanks in advance
Bernd
Hello, you can go to the github link and then click to "Latest Release" link in the description, this is the link of the actual version: https://github.com/davidegironi/advanceddatagridview/releases/tag/1.0.x.19
DeletePERFEKT - many thanks for this and a happy new year
DeleteThank you!
DeleteHi Davide,
ReplyDeleteThanks for the cool tool. I've been using this in a few projects and am able to make all the features work thanks to the sample project in the hub. I was wondering whether you're aware if anybody got this to work with binding lists or something like that instead of Datatables which forces me to add another step to convert my lists to datatables using libraries like FastMember, etc..
Thanks
Hello and thank you for your feedback! I've always using this with DataTables, it's the way the builded filter/sort string works that "force" me to use DataTable binded. Sorry about that.
DeleteHi Davide,
ReplyDeleteThanks for the cool tool.
but i still couldn't able to filter column (date time)
i am using the latest version
here is screen shots
https://i.imgur.com/Axrkbvf.png
https://i.imgur.com/1joRw8R.png
screen shot of my DB
https://i.imgur.com/DXDAWTw.png
date example
2016-10-30 20:44:36.000
Hello, thank you. It should work that way, the converted filter string seems right to me. Have you check the sample project, does it work there?
Deletei don't have jet
Deleteso i used sql db connection directly
filter must use only date format not datetime
Deleteit must be ((Convert([CreationDate], 'System.String') LIKE '%01/11/2016%')
NOT
((Convert([CreationDate], 'System.String') LIKE '%01/11/2016 12:00:00 AM%')
i solved it
Deletefile menustrp.cs
i changed to this new line
DateTime dt = (DateTime)n.Value;
string DTStr = Convert.ToDateTime(dt).ToString("dd/MM/yyyy");
sb.Append("(Convert([{0}], 'System.String') LIKE '" + DTStr + "%')" + appx);
// instead of
// sb.Append("(Convert([{0}], 'System.String') LIKE '%" + Convert.ToString((IsFilterDateAndTimeEnabled ? dt : dt.Date), CultureInfo.CurrentCulture) + "%')" + appx);
Hello and thank you for sharing your fix here, it may helps other people!
DeleteHi Davide, I followed the video but the ADGV doesn't seem to fully implement INSERT, UPDATE, DELETE functionality. Does the tool automatically perform these or do I need to write code to implement?
ReplyDeleteHello, the advanced datagridview doe not implement INSERT, UPDATE, DELELE, you have to code it on you program.
DeleteHi David,
ReplyDeleteI'm testing your powerful datagridview, but if I have one column filter active, when I edit the cell with a value not in filter selection, the row disappear immediatly. Can I edit the cells and coonfirm or validate any modified values with one external button event ?
In Excel, with apllied filter, not disapperaing rows on cell edit action, only after refiltering.
Many thanks
Hello, if I've understand what you want, you have to code a little to obrain this beyavior. That's because the filter is fixed, it's not dynamic, it means that it does not change depenging on the filtered rows.
DeleteHi Davide, any help for this error?
ReplyDeleteerror BC30002: Type 'Zuby.ADGV.AdvancedDataGridView' is not defined.
My project is written in VB.
Hello, take a look at google searching error BC30002.
DeleteWhat i think is that the type is not accessible to the reference.
Thanks for your reply.
DeleteI have solved the problem ady :)
Hello iam new in c# and i fill datagrid from a datatable how can i filter and sort without databinding or how can i i convert datatable to a bindingsource
ReplyDeleteThank you
Hello, take a look here, it may help you: https://github.com/davidegironi/advanceddatagridview/issues/24
DeleteDear Davide,
ReplyDeleteThe advancedDataGridView is working well, but how can i connect it with the advancedsearching toolbar?
Hello, take a view at the Sample project, there you can find an example to make the toolbar works.
DeleteDavide,
ReplyDeletemy email is the following:
rodriguez.fa114@gmail.com
Think that the first comment dont was inserted, i write again:
ReplyDeleteHello davide,
You are amazing, this job is wonderful. Thank you very much.
I tried to adapt it to my project by installing package v1.1.24722.8 (I think this is the latest version) and it works successfully, filter and sort correctly. But I have two little problems:
1) How can I change the language? I am Spanish speaking.
2) When I sort or filter data with DataTime type (for example) the description is not correct. The same is shown for the types of texts (Order A to Z). The same happens for the rest of the types (bool, decimal, etc.)
Please could you help me with these two little problems?
Thanks in advance, I hope you can read me and I look forward to your comments.
Thank you!
Hello Federico, thank you.
Delete1) look at the AdvancedDataGridViewSample Project. Here you will find a lang.json file. Translate it in your language, then you can set the language by using the commands (last one is for Search ToolBar) AdvancedDataGridView.SetTranslations(AdvancedDataGridView.LoadTranslationsFromFile("lang.json"));
AdvancedDataGridViewSearchToolBar.SetTranslations(AdvancedDataGridViewSearchToolBar.LoadTranslationsFromFile("lang.json"));
2) I don't understand what's the problem, sorry.
DeleteHi davide
Everything works perfectly, don't worry about the second point, it could be solved.
Again, thank you very much for your input, this work is impressive.
Regards!
That's great!
DeleteHi Please,
DeleteWhere can I find the lang.json in FRENCH
regards
Hello,
Deleteyou have to translate it. If you do this, please share the file in the git issue repository. Thanks
Super job!!
ReplyDeleteI had a problem with columns filter and sorting, but I figure that out.
I have one question/problem. I'm loading data for an excel spreadsheet (no problem there). In the searchtoolbar, the combobox, I expected it to populate from the column headers, but it didn't. Do I need call an event or something? Thanks in advance.
Thank you Aaron. To set the columns on the advanceddatagridviewseaechtoolbar you have to call the SetColumns method of the searchtoolbar passing the columns array you can get calling the .Columns property of the datagridview. You can find an example in the Sample project you can get in GitHub. Hope this helps.
DeletePerfect!! Thanks.
DeleteThis comment has been removed by the author.
ReplyDeleteHi all, not sure if it was already addressed, here follow the code I have.
ReplyDeleteif (cboSelector.SelectedItem.ToString() != "All")
{
string myTestFilter = "(Convert([MyColumn],System.String) IN ('" + cboSelector.SelectedItem.ToString() + "'))";
dg.LoadFilterAndSort(myTestFilter, "" );
}
else
{
dg.CleanFilter();
}
Hi, I'm using your Advanced Grid and everything works fine.
ReplyDeleteNow I try to add localization for German language. Most translations work fine. However those in the menustrip do not change. As example my translation for ADGVSortTextASC never shows up. Those in the toolbar and the Formcustomfilter work fine.
Is this possibly a bug or where am I on the wrong track?
Sorry - forget the previous comment. There was a missing colon in my German language file and there is something in my logic. On second load of my form everything is fine. Need to change the sequence of events.
ReplyDeleteThat's fine. You're welcome ;)
DeleteHello Davide,
ReplyDeleteI had created a WinForm with several grids of type datagridview (dgv) that include a simple filtering option. Nonetheless, a user asked if the filtering option can resemble that of Excel.
Thankfully, I came across your AdvancedDtaGridView. Great job by the way.
So, thanks to your grid, and after making a few adjustments, it is working as before with one small issue so far:
I'm adding a handler to the grid to add numbers to the header rows. It is the same code I used before (and still works using the original dgv) but I'm now getting this error:
Exception thrown: 'System.ArgumentOutOfRangeException' in mscorlib.dll
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
I've debug/stepped thru the code many times at no avail. I wonder if there is a setting I need to set or if it does not work with your version of the grid?
here is my piece of code:
Dim adgv As AdvancedDataGridView = sender
Dim row As DataGridViewRow
If adgv.RowCount > 1 Then
For Each row In adgv.Rows
row.HeaderCell.Value = (row.Index + 1).ToString()
Next
End If
it errors in the row.HeaderCell.Value line.
Any help would be greatly appreciated as I am already thankful to you for sharing your ADGV.
Yolanda
Hello Yolanda, please provide a sample solution to check the error.
DeleteHello Davide,
DeleteSorry for the delay in getting you a sample solution.
I've created a form with 2 grids for comparison.
I'm attaching the solution in a zip file.
Thanks in advance for your help,
Yolanda
not sure the zip file got attached as I don't see it in my previous reply. But Here is the code of the 2 grids I added to a form:
DeletePublic Class FrmADGV
Private Sub FrmADGV_Load(sender As Object, e As EventArgs) Handles Me.Load
'/* Load grid
adgv.Columns.Clear()
Dim newTable As New DataTable
newTable.Columns.Add("Column1")
newTable.Columns.Add("Column2")
newTable.Columns.Add("Column3")
newTable.Rows.Add("a", "b", "c")
newTable.Rows.Add("a", "b", "c")
newTable.Rows.Add("a", "b", "c")
adgv.DataSource = newTable
dgv.DataSource = newTable
End Sub
Private Sub adgv_RowsAdded(sender As Object, e As DataGridViewRowsAddedEventArgs) Handles adgv.RowsAdded
Try
Dim row As DataGridViewRow
Dim iRow As Integer = 1
For Each row In adgv.Rows
row.HeaderCell.Value = (iRow).ToString
row.HeaderCell.Style.ForeColor = Color.Red
iRow += 1
Next
Catch ex As Exception
MessageBox.Show("Error in adgv_RowsAdded: " & ex.Message)
End Try
End Sub
Private Sub dgv_RowsAdded(sender As Object, e As DataGridViewRowsAddedEventArgs) Handles dgv.RowsAdded
Try
Dim row As DataGridViewRow
Dim iRow As Integer = 1
For Each row In dgv.Rows
row.HeaderCell.Value = (iRow).ToString
row.HeaderCell.Style.ForeColor = Color.Red
iRow += 1
Next
Catch ex As Exception
MessageBox.Show("Error in dgv_RowsAdded: " & ex.Message)
End Try
End Sub
End Class
thanks again,
Yolanda
Hello, think this is something related to the For Each loop you are doing. You have to debug it with you VS.
DeleteI'm also experiencing this Exception problem with row.HeaderCell.Value. I did a side-by-side test with DataGridView and AdvancedDataGridView, code used on both is identical.
DeleteYou can start from the sample project in the github solution, and check from there. Also you can take a look at how it is used in DentneD https://github.com/davidegironi/dentned
DeleteI found the solution to the problem... In AdvancedDataGridView.cs line 1118 I added a line so that it now looks like this:
ReplyDeleteprotected override void OnCellValueChanged(DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == -1) return;
_filteredColumns.Remove(Columns[e.ColumnIndex].Name);
base.OnCellValueChanged(e);
}
but I was poking around.
Thank you for your post! I think I will add this line in the offical distribution too! It makes sense.
DeleteHi Davide, I thought a bit more about it but have not had the chance to test. Perhaps consider this...?
Deleteprotected override void OnCellValueChanged(DataGridViewCellEventArgs e)
{
if (e.ColumnIndex >= 0)
{
_filteredColumns.Remove(Columns[e.ColumnIndex].Name);
}
base.OnCellValueChanged(e);
}
Hello, this makes even more sense. I think I'll go for if if (e.RowIndex >= 0 && e.ColumnIndex >= 0) and also for (e.RowIndex >= 0) added on OnRowsAdded and OnRowsRemoved, if you can test this it will be really good.
Delete