 |
|
 |
Thanks! This was the info I was looking for.
Just one little thing: A StackOverflowException will be generated if you drag the icon-column to the very right and then resize the window.
|
|
|
|
 |
|
 |
How can i change the image for each row.
thanks in advance
|
|
|
|
 |
|
 |
How can i change the image for each row.
thanks in advance
|
|
|
|
 |
|
 |
First of all thanks for the wonderful work. You get my 5/5.
I have a small suggestion though. The DragDrop should happen only when the mouse is hovering over the grid header. If the mouse is over the cells below, the cursor should change to cross(HitTest will tell this). This is the behaviour of Microsoft Outlook. I have modified the source code to achieve this. If you want I can share the source with you.
Thanks,
Alomgir
|
|
|
|
 |
|
 |
I'm glad that you found my sample useful. Thanks for your warm words. I no longer update this sample, so go ahead and post your updates here, so that other people can take advantage of your fix.
Thanks,
Vlad
|
|
|
|
 |
|
 |
... to make it useful with DataGrid filled with SQL result? (doesn't work for me
|
|
|
|
 |
|
 |
Ok, got it. Need to set MappingName to table name.
|
|
|
|
 |
|
 |
but how can i set the image data from sqlserver in the datagrid without using DatagridTableStyle if posible?
tj.zhou
|
|
|
|
 |
|
 |
Hello,
I was particularly interested by your extended datagrid functions, mainly the icon style column in a dtg (I was looking for such one for a while). I was able to reproduce in a datagrid the icon display, but as on your sample, it can show only the 1st member of the imagelist linked to the control.
Maybe it's a stupid question, but how can we define different images and push the control to select another image index from the list into the datagrid icon column ?
Thx
Mikels
|
|
|
|
 |
|
 |
1. Need to change column datatype to System.Int32 (in designer go to dataSet1 -> Tables -> Columns -> column1 -> DataType) 2. Add a row with icon index=1 to the datatable. At the end of the UserControlWithDataGrid() constructor add: DataRow r1 = this.dataTable1.NewRow(); r1[0]=1; this.dataTable1.Rows.Add(r1);
3. Go to imageList_IconColumn properties in the designer and add another icon to the image list 4. Update Paint() method in the IconColumn,cs file to something like: object val = this.GetColumnValueAtRow(source, rowNum); int imageIndex = 0; if(val is int) { imageIndex = (int)val; } this.ImageList.Draw(g, bounds.X, bounds.Y, this.ImageSize.Width, this.ImageSize.Height, imageIndex);
|
|
|
|
 |
|
 |
There are two problems I need to solve:
First, if the column header text is long and the column width is not long enough to show all text in one line, is there any way to set the column header height bigger and wrap the header text in multiple lines?
Second, if the text in one cell is long, is there any way to auto stretch this row so that the text could be wraped and showed?
Thanks in advance for any tips.
|
|
|
|
 |
|
 |
HI
i AM IN NEED OF A WIN DATAGRID CONTROL IN WHICH I CAN HAVE MULTIPLE CONTROLS IN A CELL WHEN A NEW ROW IS INSERTED. FOR EG NEW CELL(0,0) SHOULD HAVE 2 COMBO
AND ONE TEXT BOX.pLEASE PROVIDE THE HELP
|
|
|
|
 |
|
 |
I'm not sure I follow you. I think you need to use different DataGridColumStyle objects for different columns. .Net framework comes with build-in support for coulumn style with a text box and a check-box. There are some samples on the internet about how to add a combo-box to the cell. It's a little tricky, but possible. I beleive there is a sample somewhere on microsoft.com.
|
|
|
|
 |
|
 |
hi,
for this you can do one thing. While u get focus on to that column, you need to load a datagrid inside the column and need to give as many columns for that new datagrid and need to assign controls for each column in that new grid.
this is the way to do it.
you want this kind of control contact me
sojan_80@yahoo.com
sojan
|
|
|
|
 |
|
 |
How i can put different icon in icon column for each row. I want to show icons based on value in the table column.
Thanx
|
|
|
|
 |
|
 |
Excellent table style class in example 2, just what I was after. One question though have you done any work to handle when the vertical scrollbar appears? Currently the consumed width is calculated as though it isn't present so you end up with a horizontal scrollbar, that scrolls the width of the vertical scrollbar. (Wonder if i will get an award for the number of times I type scrollbar)
Any thoughts before I write it myself?
|
|
|
|
 |
|
 |
I remember I solved that problem. What I did is I've added a new property to the DataGridEx named "VerticalScrollBarVisible". I enumerated through the Controls collection of the DataGrid and one of the objects is vertical scroll bar. (It has distinct datatype so it is easy to identify). I cachned that object and anytime I needed to know if vertical scroll bar is visible, I would check Visible property of that cached object. Additionaly I added event handler to the VisibleChanged event of the vertical sroll bar and call ResizeLastColumn() when that event is raised.
|
|
|
|
 |
|
 |
I am looking for a way to send an event of double click on a column border for auto-resize.
|
|
|
|
 |
|
 |
This is an article on dragging and dropping column headers, why include the resizing and image support? I find this all the time in everybody's code. Maybe it's better to just stick to the subject and don't make the sourcecode any more difficult with lots of lines of code for other things. Explain that in another tutorial, if you will.
And you said this code is self explaining, but maybe it's better if you still add some comments to the code, if you don't feel like writing a complete article.
I like the image that's creating, showing what you're dropping where. Too bad it's unmanaged code.
|
|
|
|
 |
|
 |
Good point. I guess you are right. I'll split this example into pieces and will publish 3 separate projects with increasing complexity. I'm alomst done with the next revision which is even more advanced, and may be too much for people who want to learn gradually
|
|
|
|
 |
|
|
 |
|
 |
if you try to drag a column with width bigger than 256px you will get an exception.
until Vladimir will issue a newer version ( with probably a nicer solution )
you can patch it so all dragged images bigger than 256 will be clipped to 256px. as below :
go to DataGridEx_MouseMove and add the lines :
Size clippedSize = colHeaderImage.Size;
if ( clippedSize.Width > 256 )
clippedSize.Width = 256;
right before this piece of code ( notice the change in the second line )
this.m_ImageList.Images.Clear();
this.m_ImageList.ImageSize = clippedSize;
this.m_ImageList.Images.Add((Image)colHeaderImage.Clone());
colHeaderImage.Dispose();
cheers,
DaberElay
|
|
|
|
 |
|
 |
I'm working on a next version that will fix that issue. Thanks for reporting the bug.
|
|
|
|
 |
|
 |
Hi all,
First Vlad, thanks for this excellent work!
however I decided to try a bit of a different approach :
inherit from datagrid and add all your code to it.
the users of the class should only use the regular datagrid and replace their member from DataGrid dg1; to DataGridEx dg1; and thats it. no usercontrols necessary...
I unfortunatly there is no option to attach the file, so if you wan't it send me a mail, and i'll send it to ya.
Cheers,
NimCo.
|
|
|
|
 |
|
 |
A lot of you guys are mailing me to send you the class in question.
please notice the intro, the package allready contains this amandment, so you can go ahead and download it dircetly,
Enjoy,
DaberElay.
|
|
|
|
 |