|
A_Laxman wrote: ^[0-9] i am not sure... but it may be something like this one.
The correct one is [0-9].
The one you mentioned checks whether the string starts with any digit.
Thanks for the attention.
|
|
|
|
|
Thanks...
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
actually i dont know any usage and applications of enumarations can anybody explain me please
|
|
|
|
|
upadesh wrote: enumarations
Actually are called enumerations see there: [^]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
upadesh wrote: i dont know any usage and applications of enumarations can anybody explain me please
Here is the most common usage:
foreach(object o in someEnumerableObject)
{
}
Unless you meant enum in which is it used to define a list of possible values from a well defined list.
When ShowDialog() completes it returns a DialogResult . There are only a small number of possibilities for the result including Okay, Yes, No, Cancel. Instead of forcing the developer to remember the integer values of each of these results the enum can be used to provide a more meaningful way of expressing the value.
|
|
|
|
|
you could use Code Search[^] to find some (a bazillion) usages of foreach, and analyze and interpret them.
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
Hi,
I am having an issue setting the column order on a grid:
I created a DataTable with some bound and some un-bound columns.
I created a DataGridView using the DataTable for input.
I set the .DisplayIndex for all the DataGridView columns
I then created a DataView using the DataGridView.DataSource
I assigned the DataGridView.DataSource to the DataView.
My columns to not appear in the correct order when first displayed, however, if I change the row filter on the DataView by responding to a GUI event, everything updates and my columns are in order.
Also, another table using only bound columns displays correctly the first time.
Has anyone had a similar issue or want to take a crack at this problem?
Thanks in advance,
Pualee
|
|
|
|
|
You can change column order by setting the DisplayIndex property.
Take in mind that no 2 columns can have the same index.
If the data is not very likely to change, you could manually add the columns in the datagridview via the IDE, and turn off autogeneratecolumns.
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
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.
|
|
|
|