|
|
Comments and Discussions
|
|
 |
|
|
|
|

|
Hello. I have a question: Does this grid can create a specific class to load?. Explain this: maybe the grid could create a class with a typed property for each column of the grid and the same type as expected each column. Something similar to typed DataRow in a DataTable.
Sorry for my english. Jorge (Vigo - Spain)
|
|
|
|

|
Hi
It is very useful and like it very much.
In the print screens it says dateformat as dd.mm.yyyy
But when i implement it shows mm/dd/yyyy.
I am using MS access database to connectt. Please hep to show in dd-mm-yyyy/dd.mm.yyyy
i have set DBdateformat="mm-dd-yyyy". it did not change in the calandar show
|
|
|
|
|

|
we are using more complex level of grid
|
|
|
|

|
Excellent article. Thank you.
I would like to add this to my Visual Studio 2005 Toolbox.
On the Toolbox->Data tab, I did right mouse click, .Net Framework Components, Browsed to the GenericDataGridView.dll and added that and I see it in the list and it is checked.
I clicked OK but I don't see it available anywere in the UI.
Googling around suggests I need to have it installed via a VSI (Visual Studio Content Installer) .vsi file.
Can anyone guide me so I can have this control available in my Toolbox?
Thanks for your help,
-Tom
|
|
|
|

|
How do I add columns from three tables with a inner join ?
genericDataGridView1.DataColumnsTable = "Table1", "Table2", "Table3";
|
|
|
|

|
Im using Visual studio 2008. I downloaded the app & it does not open in visual studio.
What am I doing wrong ?
|
|
|
|

|
Hi...
I want to stop the tab key navigation in datagridview. if i press the tab key in a certain cell it must stay in the same cell.
how can i do this?
Ven Kates
|
|
|
|

|
Can we add nested grid using this?
|
|
|
|

|
Nice grid but when I set it to editable and change a value it can not find the next columnname. So when it goes into the for loop it says column name "columnname" not found?
It happens with this if (this[kValues[i], rowNumber].Value is System.DBNull)
I looked into it but cannot find what is wrong. The rows are shown in the grid and I can change it in the grid row but as soon I select the next row and it goes into the Row_Save it failes.
Can you advice.
Thanks in advance.
|
|
|
|

|
could you check that you have set the properties in picture 1?
I hope this will solve the problem.
|
|
|
|

|
Ok here is what i did:
genericDataGridView2.DataColumns = "ContractID, ContractNR%, ContractPrijsNR, Stuksprijs, Aantal";
genericDataGridView2.DataWhere = " where (ContractNR = " + "'" + txtContract.Text + "')";
genericDataGridView2.DataColumnsTable = "tblContractDetail";
genericDataGridView2.DataConnection = "server=server; uid=user; pwd=PW; database = DB";
genericDataGridView2.FillAll();
genericDataGridView2.AddCombo("ContractPrijsNR", "Omschrijving", "tblContractPrijs", "Omschrijving", "ContractPrijsNR", " order by Omschrijving");
genericDataGridView2.AddValidation("Aantal", true, GenericDataGridView.GenericDataGridView.ValidationStyle.NumericInt, "must be an integer");
As you can see I added a DataWhere in de Class this was usefull for me and this is working. I tried it whitout but that doens't change anything.
The ContractID is a Identity field. It is failing in de the second row, so it is telling me that ContractNR doesn't exists.
I will do some more debugging to find out what the problem is. I hope you have some ideas as wel.
Thanks in advance.
|
|
|
|

|
Found the problem. Had to trim the kValues so there are spaces somewhere and thats why it cannot find the columnname.
modified on Thursday, May 29, 2008 6:05 AM
|
|
|
|

|
Yildirim bey,
I was looking for a MaskedTextBox in a DataGridView and found this solution. At first sight, it could be very useful. You include the editing controls in the same way, like MS's example does with CalendarColumn.
But it's not useful to combine this with DbConnection und saving changes directly: In real applications, one should set apart the GUI like DataGridView from the data editing via DataTable and data storage via DbDataAdapter. Additionally, you are using SqlClient only - in the same cs file. If anyone uses Firebird or Oracle or MySql or anything else, one must change all the source code. It's a pity...
Good work: Preparing CalendarColumn, MaskedTextColumn, MultipleComboboxColumn. See also my post in "Bug in Mask".
Best regards,
Juergen
|
|
|
|

|
Hi Juergen,
You are right about the mask and also the connection string. The control can be extended, that is why i also put the source code to the article.
Thanks for your nice contribution.
|
|
|
|

|
genericDataGridView nesnesine ekledigim combobox çalisma zamaninda hata firlatiyor.Yazilan herseyi düzgün bir sekilde yapmama ragmen genericDataGridViewComboBoxCell value is not valid diye bir hata aliyorum yardimci olursaniz sevinirim..
|
|
|
|

|
Hangi adimda bu hatayi aliyorsunuz e tarz bir icerikteki datasource'u yuklemeye calisiyorsunuz. ykocdag@yahoo.com adresime elinizdeki kod'u ve probleminizin hangi asamalarda kaynaklandigini gosteren detayli bir mail atarsaniz yardimci olabilirim.
Tesekkurler,
H.Mehmet Yildirim Kocdag
|
|
|
|

|
Hi,
I have set validations for each column of the grid.But when i doesnt enter any value in a particular column i cannot go to anyother column..because Validation will work and corresponding error message is getting displayed..I would like to avoid valiadtion when i doesnt enter any data in a particular column..Hw to do that?Also i would like to know what bool blank control is ..
Thank u...
|
|
|
|

|
Hi Mathew,
if you set the blank control as false, it is not neccassary to enter any value for the column.
Thanks,
Yildirim
|
|
|
|

|
Hi,
I would like to know how we can set validations as column property during design time...
Like we set Calender Column as Column type in the grid during design time itself.
thank u....
|
|
|
|

|
Hi Mathew,
You can add validations to the control via using AddValidation function. The parameters of the function are ColumnName,BlankControl,ValidationType and ValidationMessage. You can also find the usage of the function in the article. You can also add new validation rules to the control by adding new validation functions and styles to the control.
Please feel free to ask any question.
Thanks,
Yildirim Kocdag
|
|
|
|

|
Hi,
Thanks for ur reply.
Actually i wanted to set the validation as properties in the grid at design time itself.Rather than adding it using Grid.AddValidation()...in the code.
I thought of adding a ComboBox in the properties column of each column of grid and also a text box for entering the Error message.
So, when we add columns during design time, we will be able to set its validation also along with it.
But i dont have an idea how to start on it.....Any help on this...
|
|
|
|

|
For design time, this control will not work.
You can make search in msdn about customizing the control with designtime works. I hope you will find some samples.
Thanks,
Yildirim
|
|
|
|

|
Hi,
this is a great article!!!!
I have a doubt regarding calendar column .I need to add rows during runtime with Calendar column in a particular cell.
Say,for example.
I have added columns OrderID,OrderDate,Frieght to the grid during the design time .And Set OrderDate column as CalenderColumn.While running the application ,all the data are getting displayed.
Now I have a button named "addrow".When i click it, i need to add a new row .And while clicking the save button everything shud get saved.But Im unable to add a new row with Calendar Control as Column type..
Plzzz helppp...Thanks a lot...
|
|
|
|

|
Hi Mathew,
I dont think that it is possible during runtime via this control. However you can change the control as it can add new column during the runtime.
Thanks,
Yildirim Kocdag
|
|
|
|

|
Hi,
Thanks a lot for the reply..
I got it...this is how i did.
CustomDataGridView.CustomDatagrid.CalendarCell cel = new CustomDataGridView.CustomDatagrid.CalendarCell();
cel = CustomDatagrid.Rows[i - 1].Cells[2] as CustomDatagrid.CalendarCell;
cel.Value = DateTime.Now.Date;
So each time when we add a new row,that particular cell will generate calendar column with that days datetime...
|
|
|
|

|
Thanks for your greate code, but there is a problem if we need to add two (or more) MaskedTextColumn with different masks strings? in this case the control keeps one mask only. How we can overcome this problem ?
|
|
|
|

|
I added it to my bug list for the new version. Thanks.
|
|
|
|

|
Can you please send me a fast solution?
Thanks in advance.
|
|
|
|

|
This is not really a bug, but caused by the framework itself: The DataGridView contains one specific EditingControl for all columns. I saw this when I wanted to use TextBoxColumns with CharacterCasing.Upper in one column and CharacterCasing.Normal in all others.
As Workaround you can use the DataGridView.EditingControlShowing event: read the CurrentCell.ColumnIndex and set e.Control's mask to the required string, similar like this:
void DgvEditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (e.Control is MaskedTextBox) {
MaskedTextBox box = e.Control as MaskedTextBox;
switch(dgv.CurrentCell.ColumnIndex) {
case 3:
box.Mask = "990";
break;
}
}
}
This mask will be valid until this event is called the next time, i.e. the focus is set to another cell.
To improve this, you could add a Dictionary<string, string> to contain the mask for each column.
Regards, Juergen
modified on Saturday, April 19, 2008 6:51 AM
|
|
|
|

|
This is really a very helpful code. Thanks for this.;)
|
|
|
|

|
Hi
It is nice control but I have lot of exceptions whenever I try to change the date using date picker.
Also is there a way to have empty date in default?? Is there option to localize the date control?? [ That is the date control shows the dates according to the culture of my application and override the user's machine culture]
Thnx in advance for help...
|
|
|
|

|
Playing with your control (your code as downloaded) I ran across this problem.
I 'Start debugging', the contol comes up, I click anywhere in the Order Date column and activate the Calendar control. Change the date or even just select the same date. Then I click anywhere in the Freight column and the DataGridView control stops responding. The only thing I can do is increase/decrease the row height or column width.
I have to use the menu bar to 'Stop debugging'.
Any clue to why this is happening???
Thank you,
P.S. You provided a .vb version of the form. Could you provide a .vb version of the class??
|
|
|
|

|
It is possible that you are having a difficulty to storing the data to cell, you can check the problem via debuging to control. It is highly possible that the problem is about date format of database or client.
I have already focused writing new control which is generic web based datagrid. Therefore, I have no time to convert the control vb.
Thanks for your posts.
H.M.Yildirim Kocdag
|
|
|
|

|
Thank you for your quick reply and your suggestion. I was using an un-altered copy of MS Northwind database and the freight column was typed as 'money'. As soon as I changed your line:
genericDataGridView1.AddValidation("Freight", true, GenericDataGridView.GenericDataGridView.ValidationStyle.NumericInt, "must be an integer");
to
genericDataGridView1.AddValidation("Freight", true, GenericDataGridView.GenericDataGridView.ValidationStyle.Numericdouble, "must be a deciaml.");
everything worked as advertized.
Thank you for sharing your code and your help.
As for my request about a version in VB, I apologize. I only asked in case you already had a vb version laying around. It turns out I found a really good conversion program, InstantVB, which did an excellant job of converting it. Now I have something I can look at and understand.
I could have just used your .dll, but I wanted to try to understand how you did things.
Again, Thank you,
|
|
|
|

|
Without a license specified, this code is copyright with all rights reserved for the author. This means that we can look at the code, but we cannot use or change it.
Could you please attached a license or declare that this code is in the public domain?
Thanks
|
|
|
|

|
You can use or change the control. It is an open source project, you can ask kindly to change or use it if you think it is really necessary.
Thanks for your contribution.
H.M.Yildirim Kocdag
PS: New generic web based control is coming soon. I will publish it earlier than it is expected. May be in this week
|
|
|
|

|
Hi all,
now there is a great component that adds some featues to the basic DataGridView control. The most valueable thing is that it does not inherit the control, just integrate in it. I found the DataGridView Extension very usefull, it adds an export to Html, Excel, Theme management, Additional columns and so on. The most amazing for me thing is that it saves all operations to the DataGridView control, like columns reordering, resizing, hiding and so on ... you can check it on http://www.completit.com/Products/DGVE/Overview.aspx
Think this will help you a lot.
Alexander Alexandrov
|
|
|
|
|

|
I met the same error while attempting to use my own control as the DataGridView.EditingControl, and it was in the same situation (assigning value to the control`s Value property).
I didn`t analyze the "Generic DataGridView" control, but evidently the featured editors in this control must implement the IDataGridViewEditingControl interface, and the custom CellTemplate class must inherit DataGridViewCell (or maybe DataGridViewTextBoxCell) class. If they do, I suppose that the error occurs in the "InitializeEditingControl" method of the inherited DataGridViewCell (as it was in my case).
If your error occurs in the "InitializeEditingControl", try to assign "initialFormattedValue" parameter to the ctl.Value instead of "this.Value". In my case the problem was solved in this way.
|
|
|
|

|
How can I Retrieve Data from DAtagrid Row ?
|
|
|
|

|
Hey.
Iøm desperet to add a comboc to a datagridview. Been trying and trying and I just can't seem to find a good example until now. This articale looks very promising. When I try to start the program I does not work. When I examin the code it whats to execute the method FillAll which contains a database call. Obovious this is where the program gets it's raw data. But my code does not contain a database for the program to read. Can someone help me here?
Thnaks in advance,
Bo
|
|
|
|

|
The DataSource is a SQL server that has the Northwind (Microsoft sample) database attached. Point to your local copy. Form1.Designer.cs lines (approx.) 38-47 should solve your problem. // // genericDataGridView1 // this.genericDataGridView1.AllowUserToOrderColumns = true; this.genericDataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.genericDataGridView1.DataColumns = "OrderID,CustomerID%,OrderDate%,EmployeeID,Freight,ShipPostalCode%"; this.genericDataGridView1.DataColumnsTable = "Orders"; this.genericDataGridView1.DataConnection = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind;Data Source=itgeek2;"; this.genericDataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; this.genericDataGridView1.Location = new System.Drawing.Point(0, 0); this.genericDataGridView1.Name = "genericDataGridView1"; this.genericDataGridView1.Size = new System.Drawing.Size(829, 427); this.genericDataGridView1.TabIndex = 0; ... Here my "Data Source=itgeek2" will connect to a server other than "localhost". Edit all the connection strings just to be safe. dude_dude
|
|
|
|

|
Hi Yildirim,
Thank you for your excellent contribution.
I was wondering if you had customized the class to also work with a
GUID instead of an Identity column ?
Many Thanks, Paul
|
|
|
|

|
"How can i add GenericDataGridView on my windows forms"
- SambathRaj.C
|
|
|
|

|
the combobox column in datagrid cant be edit, only select a item?
how i can make it editable ,that is to say, that in addition to being able to select of the list can write in the square
asdsadsadadasdsadadsada
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
A Generic DataGridView which has features of DataGridViewComboBoxColumn, DataGridViewCalendarColumn, DataGridViewMaskedTextBoxColumn, Validating DataGridView Columns and Saving any edited row with automatic created queries.
| Type | Article |
| Licence | CPOL |
| First Posted | 4 Jul 2006 |
| Views | 342,626 |
| Downloads | 11,212 |
| Bookmarked | 237 times |
|
|