|
I bad Speak and Write English so I am Sorry.
C# 4.0 Datagridview -> " dataGridView1.Rows[0].Selected = true; "
I also want to make this Devexpress Grid Control.
I'd appreciate it if you can help.
Already Thanks .
|
|
|
|
|
FocusedRow on the TableView is probably the property you want. Just set it to an instance of the row you want to be focused.
<dxg:GridControl x:Name="grid"
ItemsSource="{Binding GridSourceRecords}"
AutoPopulateColumns="True" >
<dxg:GridControl.View>
<dxg:TableView x:Name="GridControlTableView"
FocusedRow="{Binding SelectedRecord, Mode=TwoWay}"
NavigationStyle="Row"
AllowEditing="False"
AllowBestFit="True" AutoWidth="True">
</dxg:TableView>
</dxg:GridControl.View>
</dxg:GridControl>
|
|
|
|
|
Thank you for the answer
But I am doing my project in C # 4.0 .
And My project is a windows form application .
Jason Gleim wrote: <dxg:GridControl x:Name="grid"
ItemsSource="{Binding GridSourceRecords}"
AutoPopulateColumns="True" >
<dxg:GridControl.View>
<dxg:TableView x:Name="GridControlTableView"
FocusedRow="{Binding SelectedRecord, Mode=TwoWay}"
NavigationStyle="Row"
AllowEditing="False"
AllowBestFit="True" AutoWidth="True">
</dxg:TableView>
</dxg:GridControl.View>
</dxg:GridControl>
This code is asp?
Can you give me the C # code?
|
|
|
|
|
Oops... sorry about that. That is the xaml for a WPF or Silverlight application. However, the principles are the same, you just have to do them in the code. You need to know what you named the grid and what you named the view attached to the grid. The view will be either a TableView or a TreeView. Assuming you are calling the grid 'myGrid' and using a TreeView called 'myTreeView' the following code will deselect any selected rows and then select the row you specify by index:
private void myTreeView_SelectRow(int selectRowHandle)
{
if (myTreeView.SelectedRows.Count > 0)
{
int[] rowHandles = myTreeView.GetSelectedRowHandles();
for (int i = 0; i <= rowHandles.Length - 1; i++)
{
myTreeView.UnselectRow(rowHandles[i]);
}
}
myTreeView.SelectRow(selectRowHandle);
}
Of course, the selectRowHandle has to be a valid row handle. The row handles are internal row identifiers which are not always in order. The user may sort or filter the data in the grid which changes the presentation. However, the row handles will always stay the same matching up to the row they originally pointed at regardless of how the user changes the way the data is displayed.
You can get the row handle by passing the desired row object to
myTreeView.GetRowHandleByTreeElement(rowObject);
So you might write something like:
int selectRowHandle = myTreeView.GetRowHandleByTreeElement(dataCollection[0]);
where dataCollection is your array or collection of data objects that the grid is populated with.
Another useful function is to know if the user had selected a row. If you want to know that, you have to hook the SelectionChanged property of the TreeView:
myTreeView.SelectionChanged += new GridSelectionChangedEventHandler(myTreeView_SelectionChanged);
The GridSelectionChangedEventArgs parameter of that event handler exposes a "ControllerRow" property which is the row that the user clicked. You can also use the GetSelectedRowHandles as illustrated above to get all of the selected rows in response to the user's click.
Hope that helps!
Jason
|
|
|
|
|
Thanks, but this code is enough.
gvNobet_Listesi.FocusedRowHandle = 3;
|
|
|
|
|
Hi,
How can I download multiple files in same time with my C# applicaion, like is utoorent applicaion.
I have list of docx files and i want to download all of them in same time.
Thanks
|
|
|
|
|
By downloading each file in a different thread.
|
|
|
|
|
Where from?
cdpsource wrote: like is utoorent applicaion So are they torrents? Or are they on a HTTP server? Or something else entirely?
Anyway, consider using asynchronous methods instead of explicit threads.
Or, if you want to be fancy, use one thread and Socket.Select[^]. You probably only have one network interface, and then using more than one thread to read from multiple sockets just means they end up taking turns anyway - a waste of resources, unless they do some significant processing with it (starting an asynchronous file-write wouldn't be significant).
|
|
|
|
|
Hi all,
I have a method:
public static bool LoadDouble(string[] Data, string Name, out double Result)
This method looks in a CSV file for a double value associated with a string value and uses this double value to initialize a Calss property.
For example:
LoadDouble(lines, "LOA", out Robot.LOA);
Now, I would like to go through all the Class properties automatically.
So I started with:
foreach (var prop in Robot.GetType().GetProperties())
{
LoadDouble(lines, "{0}", out *******);
}
But I don't know what to use in the out argument (shown ****** above).
Does anyone have a good idea?
Many thanks,
Stephane.
|
|
|
|
|
Your function LoadDouble is a contract to return a boolean value, when called; you don't show what you do with that boolean value.
The fact that .NET lets you "get away with" calling the function without doing anything with the boolean result, that you can compile a call to "LoadDouble(lines, "LOA", out Robot.LOA);" without using the boolean result, without error, is, imho, a violation of the whole spirit of a strictly-typed language. And, it's just poor programming.
Your function requires, as its last parameter, a pointer to a variable of Type Double declared with 'out: 'Result. The compiler will enforce that requirement.
Your function promises that its 'Result parameter is passed a pointer to a variable of Type Double declared with 'out: anything in the function that modifies the value of 'Result modifies the value of the external variable you passed in.
So when your function returns, you have two "results:" one's a "nameless" boolean, which, in this case, you are not using, and the other is the possibly modified value of Robert.LOA type Double variable.
There's not enough information here about where you are trying to achieve to say much more, but my sense is that if you are asking a (implied) question like, "I don't know what to use in the out," then you need to study the fundamentals of .NET programming, and the nature of function calls, and the use of 'out, and 'ref to return modified values to variables external to a function's scope.
I also suggest you post this type of question on the C# Q&A forum, which is more appropriate.
good luck, Bill
~
“This isn't right; this isn't even wrong." Wolfgang Pauli, commenting on a physics paper submitted for a journal
|
|
|
|
|
Why do you think this question is more appropriate for quick answers Bill?
|
|
|
|
|
You need a temporary variable for the "result" of the LoadDouble function, and then set the corresponing property of your object. I.e. something like
foreach (var prop in Robot.GetType().GetProperties())
{
double tmp;
if(LoadDouble(lines, prop.Name, out tmp))
{
prop.SetValue(Robot, tmp);
}
}
(assuming that "Robot" is the name of an object)
|
|
|
|
|
How to bind SQL data to RadHtmlChart-pie telerik control? All example are just binding static data only, i want to know how to bind sql query result (Name and total) columns in RadHtmlChart-pie?
|
|
|
|
|
Your question indicates a dramatic lack of understanding, the demo will show you how to bind DATA (a collection) to the chart, whether it is static or sourced from the database is your job.
Make a connection to the database
Use a command to query the table(s) you need
Get the results into a collection (presumably name and total)
Use the demo to give you an example of how to bind the collection to the chart.
Get a book on the subject and work through the examples you will enjoy programming a lot more with a deeper understanding.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have a Treeview with checkboxes. I want to be able to click on a checkbox and change the node BG color. If the checkbox is unchecked then I want to default BG color. I've searched around and saw some things that were close but didn't exactly do both of these things.
Thanks for any help...
|
|
|
|
|
Assuming you are using winforms - you don't mention your UI. Look for a NodeClick event, in that event you write your code based on the content of the node (sender, although the sender may be the treeview and you need the SelecteNode).
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
Thanks...with your help, I got it to work...in this case with that little 'e' arg:
private void treeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
if (e.Node.Checked)
{
e.Node.BackColor = Color.Yellow;
}
else
{
e.Node.BackColor = Color.White;
}
}
|
|
|
|
|
BTW, I placed my cursor on the 'TreeNodeMouseClickEventArgs' argument in VS 2012 and pressed F1 for the MSDN help on what that 'e' represents and it mentioned nothing about it. What is that called anyway?
|
|
|
|
|
Please start posting these kinds of questions in Q&A, clearly tagging them to indicate if they are WinForms, WPF, or whatever.
My sense is you are not spending enough time really studying how to use .NET controls, and you are asking for "more help than you really need," far too frequently.
Do you have a good book on basic WinForms programming with example code for you to study, and use ?
imho, there's no substitute for hands-on careful study, on your own, with the WinForms Controls: most of them are really kind of "fossils" from the old days of COM and ActiveX, dressed-up for the .NET party, and each of them has their own "quirks."
The Visual Studio IDE and Property Browser are great tools for studying what the defaults of Control Properties are, and what Properties, and Events, and settings, are available. Experiment !
imho, you also need to spend a little time studying the CodeProject guidelines, and how CP works.
I, and others will, I'm sure, be happy to assist you to "walk forwards along" the path towards mastery of WinForms, but I, and most likely others, will not "carry you;" if we did, you would not really learn.
yours, Bill
~
“This isn't right; this isn't even wrong." Wolfgang Pauli, commenting on a physics paper submitted for a journal
|
|
|
|
|
I'll post in the Q&A as you suggest. I'm a bit older and the C# and .net coding is harder for me to grasp. I do spend a lot of time googling for answers but often the code I find I just don't understand it.
For example, I do see that Sender arg a lot and try to use it like Sender.Checked on a node checkbox but that doesn't work. I also see the e args and try using e.Checked and that doesn't work. sometimes the this. member works ok and other times not.
Seems to me if your coding in C# that the C# group would be where one should post vs the Q&A but I'm sure you have a reason for asking me to not post here in C#.
|
|
|
|
|
Hi RFresh,
It's not my intention to be critical, or patronizing, but I do think that if you are at the point where you don't have a clear grasp of the fundamentals of what a WinForms EventHandler, and its sender/EventArgs parameters, are, you may be studying "hard," but not "smart."
I strongly suggest you start off by using a resource like this free book, "Dot Net Book Zero," by Charles Petzold [^], and bear down it. Or, Jesse Liberty's over-view books on C# are excellent (O'Reilly).
If you are coming from a deep-background in COM, ActiveX, C/C++, to WinForms, then I'd recommend Chris Sell's book on Windows Forms (Addison-Wesley); disclaimer: I was a paid technical editorial assistant on that book.
Just to be clear, my opinion that the type of specific questions you are asking on this Forum (now) are best served in Q&A, are just my opinion, and I do not represent, or speak for, CP in any way.
The general idea is that forums like this one are meant to be for discussion of broader issues in using C# ... but that's my interpretation.
good luck, Bill (who started programming after age forty)
~
“This isn't right; this isn't even wrong." Wolfgang Pauli, commenting on a physics paper submitted for a journal
|
|
|
|
|
Bill,
Thanks for the pointers...I will get Charles' book.
|
|
|
|
|
I added the 'Menu' item to VS 2012 Express (using C#) toolbox but its disabled. At work I'm using VS 2012 Premium and added the Menu item to the toolbox and it did not disable it and thus I could make use of it.
Anyone know why the Express version might be disabling the Menu component on the toolbox menu?
Thanks...
|
|
|
|
|
I'm trying to save one of my settings.settings fields when I close my VS 2012 C# app but I'm getting an error saying this is a read-only property. Where so I change it to read/write?
Thanks...
private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
{
Properties.Settings.Default.emailAddress = "someone@isp.com";
}
|
|
|
|
|