Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Why I don't like the datagrid control?

 

Hello everyone,

 

Can you tell me why the datagrid control from the .net framework sucks so much? I must admit that if you want to do some simple things, like the classic master/detail view or just showing a dataset, you're fine but don't go further.

 

Where is my SelectionMode property? How come I cannot easily get a doubleclick event on a cell or on a row?

 

I wanted to create a simple row selection datagrid using the doubleclick event on a row to confirm the selection. I can use this or even this for the row selection but both solution have drawbacks. The first one is graphically ugly and the second one doesn't work well with the readonly property set to true. For the doubleclick event, I could use the solution that works well when I'm not using the row selection code or use my own personal favorite that simulate the doubleclick (using the row selection code):

	Private LastTicks As Long
Private ClickCount As Integer = 0
Private ClickedRow As Integer = -1
Private Sub DataGrid1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseDown
	'TODO: Find the real doubleclick delay !
	If e.Button = MouseButtons.Left Then
		Dim HitInfo As DataGrid.HitTestInfo = DataGrid1.HitTest(e.X, e.Y)
		If HitInfo.Type = DataGrid.HitTestType.Cell Then
			If ClickCount = 0 Then
				ClickCount = 1
				LastTicks = DateTime.Now.Ticks
				ClickedRow = HitInfo.Row
			ElseIf ClickCount = 1 AndAlso HitInfo.Row = ClickedRow AndAlso (DateTime.Now.Ticks - LastTicks) < 500000 Then
				Debug.Write("We've got a DoubleClick!")
			ElseIf ClickCount = 1 Then
				LastTicks = DateTime.Now.Ticks
				ClickedRow = HitInfo.Row
			End If
		End If
	End If
End Sub

 

Was there someone sleeping at Microsoft when it was time to create the datagrid control or what?

 

Am I oblige to buy one of those really expensive .net controls (here, here, and here) to get basic features from a grid control? Will I have to hack that grid control or build one from scratch ?

Edited by Robby
  • Moderators
Posted

You have a couple of choices; build your own or buy one.

Either way, your statement "...the datagrid control from the .net framework sucks so much..." is really uncalled for.

You seem to have found several solutions, so what exactly are you asking.

Visit...Bassic Software
  • *Experts*
Posted (edited)

I suppose this post is representative of the risk inherent in pushing code writing in a visual environment to the point of relative ease that has been achieved. The risk and the benefits of a more structured, coding environment merge as writing apps becomes more accessible to the masses and an appreciation for the complexity inherent in the "creating" of the elements available in which to present our information is lost. It would seem the dissastifaction lies in the desire to have the work of "creating" already completed. "Creating a robust grid" is much different than using a pre-built control. The visual presentation of data is only part of the creative work in a well written app.

The visual elements all need to have code written for them to be implemented by our apps. The datagrid is a complex control that does a tremendous amount of that work for us even without customization. The .net controls you can purchase are expensive because they require experience, hours of work and a certain amount of artistry to create. They do not however come preconfigured for your specific implementation without a cost. That cost is the price of good code. And therein lies the risk of making writing apps in a visual environment progressively easier. We lose the ability to write good code and become graphic designers.

Edited by jfackler
  • 5 weeks later...
  • *Experts*
Posted
And if it's in the Tool Box, there should be no need to customize it. Microsoft should have done that. What happened to RAD - Rapid Application Development?

 

 

Being in the Tool Box says nothing about customization. The more complex the control, the more diverse the means of customization. The fact that the Datagrid is complex to customize, simply speaks to the complexity of its underlying code which Microsoft did write for you. What happened to RAD? Try writing a DataGrid class yourself and appreciate the amount of RAD you get from it's un-customized instantiation.

 

This argument simply supports my previous statement, we are becoming graphic designers, wanting someone else to do the base work of writing the underlying code. As graphic designers we blame the developer for the inflexibility of the code they wrote and which we are using without writing a single line. (Kind of arrogant don't you think?) Reminds me of the joke about the engineer and the manager....

 

 

Jon

Posted

Hi.

 

Concerning the DataGrid ...

 

I just need to format a DataGrid row (i.e. change the text color) based on the value of some cell. I've researched this quite a bit and have only found the following:

 

http://www.codeproject.com/useritems/CustomDataGridsAndDesigne.asp#xx486254xx

 

Does anyone know of a simpler way of doing this? And in VB.NET (rather than C# as given in the example)?

 

For those interested, I received a reply on the Microsoft .NET Framework Windows Forms forum saying that such functionality might be added to the next version of Visual Studio.NET ...

 

http://www.windowsforms.net//Forums/ShowPost.aspx?tabIndex=1&tabId=41&PostID=5556

 

Thanks

Posted

Well all I can say is that a great deal of the stuff available in VS is new to me and as such provides an interesting challenge to learn how to use them for my specific purposes.

 

I only started using DataGrids yesterday and have already learned so much about them which give a warm glow of satisfaction.

 

To be in a position whereby you get angry, worked up or whatever and start venting it toward MS is defeatist. Work at making it do what you want it to do and seek help from members here in a friendly manner. Being irrate will not prompt anyone to help.....

My website
  • 2 weeks later...
Posted

hog: I rarely get angry and I wasn't when I wrote this post. I just like to see how people react to it and push things a bit.

 

uidgreg: Thanks for the post but I wasn't looking at changing the color of a row.

 

As for the grid, I went back to an old good activex control that doesn't support ADO.NET.

  • 1 month later...
Posted

This control is awful.

I understand that it is complex, but the documentation and examples Microsoft provide are trivial and insufficient to use it in most real applications. Even worse is that you can make calls to the control through the public API that will cause your application to hang or crash. I also found that it allocates MessageHandlers behind the scenes that do not always get properly released and can lead to memory leaks.

  • 4 weeks later...
Posted

I must agree with Co2 on that. I work with this component from the begining and I'm getting used to it.

 

Of course the new Grid is very powerful and allows you to do virtualy anything, caus you now have access to (almost) all objects layer that compose the grid itself.

 

BUT MS should have done a better implementation of some basics for RAD. I don't think it's normal to have to count times between the click in the grid and the click in the TextBox to get a DoubleClick !

Now go on, boy, and pay attention. Because if you do, someday, you may achieve something that we Simpsons have dreamed about for generations: You may outsmart someone!

--Homer Simpson

Posted

jfackler ... your talk about programing everything from dust and have to put myself on my nees thanking MS for the worst grid I've ever worked on is out of any question...

 

I'm not becoming a graphic designer, I just have to maximize my production time, If buying a Grid that cost $400 will spare me a week time job and even do things that I could not even imagine with the MS DataGrid it worth every cent it costs...

 

See the DevExpress XtraGrid at http://www.devexpress.com and tell how much time would you need to do a quarter of the functionalities with the DataGrid! (I say a quarter because the others 3/4 are just impossible to accomplish!)

 

:D

Software bugs are impossible to detect by anybody except the end user.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...