|
I set display index as follows:
Int32 i;
i = 0;
dgvItem.Columns["X"].DisplayIndex = i++;
dgvItem.Columns["Y"].DisplayIndex = i++;
dgvItem.Columns["Z"].DisplayIndex = i++;
So I know I'm not duplicating indexes. I think autogeneratecolumns could get me in trouble (not sure) as I am constantly resetting the filter on the DataView and then resetting the DataGridView.DataSource = DataView. I do not know if this operation would clear and re-add the columns or not. I kind of expect it would since the columns come up wrong, but then correct themselves after changing the DataView filter the first time.
|
|
|
|
|
On second thought, I think you are right.
I have been trying to figure out how to eliminate the necessity of resetting all my column properties each time I update the filter. The columns will never change, just the records. If I manually add the columns and disable the autogeneratecolumns, I suspect I will only have to set the properties once and save a little bit of overhead when changing the records displayed...
Thanks!
|
|
|
|
|
Your welcome. Sometimes the IDE holds the key there are some other shortcuts you can take this way like making checkboxcolumns and the likes.
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
hello all,
could some one tell me how could i bind the individual columns, already created to a dataset or a datatable during runtime.
thanks in advance.
Keshav Kamat
India
|
|
|
|
|
could you give us an example of what you're trying to achieve?
because binding different columns to different datasources doesn't make much sense to me. Might just be me though
Please clarify.
public object BufferOverFlow<br />
{<br />
__get { return BufferOverFlow; }<br />
__set { BufferOverFlow = value; }<br />
}
|
|
|
|
|
ya sure.
well here is my case.
i have a database, which has several columns. I need to modify the contents of a single column. Looking at a different side, binding a single column to a separate data source doesnt make sense to me either.
what I really want is to modify the contents of a cell of a column of a datagrid.
Can i do it using a datatable or a dataset, coz it is much faster, than accessing a datagrid as Datagrid1.Rows[i].Cells[j].
m trying to modify a cell. how to do it, if i bind a datagrid to a datatable.
Keshav Kamat
India
|
|
|
|
|
You can edit individual cells in DataTables in the same way as you edit cells in a DataGridView.
You can (or have to) use DataTable.Rows[i].Cells[j]...
public object BufferOverFlow<br />
{<br />
__get { return BufferOverFlow; }<br />
__set { BufferOverFlow = value; }<br />
}
|
|
|
|
|
well ok.
as u said in the previous replies,
when i try to bind a datagrid to a data table and try to access the cell or the row count of the data table, it says object reference not set. it comes null.
here is how i try to bind a datagrid to a datatable.
DataTable dt1=new DataTable("dt1");
dt1 = (DataTable)LoggerDatagrid.DataSource;
please tell me, if I am making a mistake anywhere.
thanks in advance.
Keshav Kamat
India
|
|
|
|
|
|
You're doing it the wrong way around.
It should be :
LoggerDatagrid.DataSource = dt1;
now your datagrid should be populated, and then you can start looking for cells to edit.
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
I have some problems with destroying object after using.
1. How can I dispose the form with many events registered and some global fields that has to be destroyed? Or it will destroy automatically?
2. If my class registers some events from other objects (use +=), do I have to unregister all the events (use -=)on its Dispose() method? I afraid that the objects firing events will stay still in heap if I dont do that.
Thx for you answers.
|
|
|
|
|
How do you know you have a problem? What are the symptoms?
It is my understanding that all managed references are cleaned up automatically, however, if you look up discussions online, you will see everyone argues about whether or not to call dispose() explicitly. Personally, I don't clean up unless I know its necessary, ie calling Close() on a connection. Even this doesn't really close the reference, but just frees it back to the connection pool.
Pualee
|
|
|
|
|
Pualee wrote: about whether or not to call dispose() explicitly
Anyone saying you should not call Dispose explicitly is wrong wrong wrong!
|
|
|
|
|
For my personal education, would you care to elaborate. This is a topic I have really been trying to grasp lately. I come from a different environment where I would expect to clean up all my references, but in C# I thought this was automatic. As stated earlier, I see strong opinions on both sides.
Is calling Dispose() just good practice, or is it actually necessary to prevent memory leaks and other problems?
Thanks,
Pualee
|
|
|
|
|
It is just good practice.
As long as you are in managed code only (ie no unsafe code) memory is 100% managed for you.
|
|
|
|
|
I disagree, it is not just good practice.
Calling Dispose on instances of a class that has a Dispose() method is mandatory;
the class may or may not hold unmanaged resources (encapsulation makes that
knowledge irrelevant), and Dispose() would take care of them.
So there are two basic rules:
- if you design a class that holds unmanaged resources, you MUST provide a
Dispose() method
- if a class offers a Dispose() method, you MUST call it when (or as soon as)
you are done with its instance(s).
Hope this helps.
|
|
|
|
|
Hi again. I have a little problem with Drag and Drop.
I like to Drag an item from a comboBox to a Treeview. The item then should be displayed as Node in there.
Does anyone have suggestions how to do that?
I tried the following:
private void comboBox1_MouseDown(object sender, MouseEventArgs e)
{
if(comboBox1.Items != null)
{
comboBox1.DoDragDrop(dv[lc.SelectedIndex].Row["Typename"].ToString(),DragDropEffects.Copy);
}
}
But now when i click on the comboBox the List does drop down only for a milisec. So i can't select any other item then the first in the list.
Anyone any ideas?
Would be glad if anyone could give me some additional tips about drag and drop from a comboBox to a Treeview.
|
|
|
|
|
This article (you can search articles, there's a lot of them) I found right here on CP:
ListBox to TreeView Drag and Drop[^]
it's about a listbox, but I'm pretty sure its applicable.
public object BufferOverFlow<br />
{<br />
__get { return BufferOverFlow; }<br />
__set { BufferOverFlow = value; }<br />
}
|
|
|
|
|
i want the difference between dates in javascript...
like if i gave any date that should be compared with roday date and it should give the difference...
Suresh.R
|
|
|
|
|
Why are you posting this on a C# forum?
|
|
|
|
|
Better to post this in javascript forun
in c# you can get time span by simply subtract the DateTime values
My small attempt...
|
|
|
|
|
sooreeagt wrote: hi just make it
Your title should reflect the problem you are having. It should NOT make demands of the other people using the forum.
sooreeagt wrote: javascript
You should pick your forum more appropriately. Your question has nothing to do with C#
|
|
|
|
|
please seek an appropriate forum for the discussion.
your topic is not related to the one where you have posted.
Thanks.
Keshav Kamat
India
|
|
|
|
|
Ye its pity to read out of context matters in the wrong place.
Make sure that doesnot happen again.
Your life is what your thoughts make it.
|
|
|
|
|
Hy!
I want to make a comboBox and when I want to select I have some time in Items like
08:00 AM
08:30 AM
09:00 AM
but I want to have the possibility to introduce a time like 08:05 AM,
10x
|
|
|
|