|
hi,
What is your real requirement ?. We can select more than one record in a datagrid. Select() method is used to select a perticular row. And Unselect() method doing the reverse of Select(). you can check whether a perticular row is selected or not by using IsSelected() method. I recommand you to read the DataGrid Class description in MSDN.;)
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Hello Sreejit,
I have used DataGrid_MouseUp() event and then used DataGrid.CurrentRowIndex to get the current row.
private void DataGrid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
int i = DataGrid.CurrentRowIndex;<br />
}
But how can I get multiple rows index if I have selected multiple rows.
like this>>
private void DataGrid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
for (int i = 0; i <= DataGrid.CurrentRowIndexes:confused:; i++)<br />
{<br />
int j = DataGrid.CurrentRowIndexes[i];<br />
}<br />
}
======
Yo need a brain to code.
|
|
|
|
|
//For collecting the index of selected records
ArrayList Ar=new ArrayList();
private void DataGrid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
for (int i = 0; i <= DataGrid.CurrentRowIndexes; i++)
{
/*this line will help you to deside whether row is selected or not. If yes then it will return a bool value. Else will return a false value.*/
if(DataGrid.IsSelected(i)
Ar.Add(DataGrid.CurrentRowIndexes[i].ToString());
else
continue;
}
}
So finally you will get all index of selected row in your ArrayList.
Remaing is upto you to design based on your requirement.;)
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Sreeji, Thank you very much. I appreciate your help.
======
code proj. rocks!
|
|
|
|
|
Hi, I wonder if it is possible to detect somehow (from C# app) when the Windows plays some specific .wav file?
What I wanna do is to "subscribe" for that event and do my job when some specific .wav file gets played.
Any ideas?
thanks!
|
|
|
|
|
You're most likely going to be able to do this simply by a mechanism that watches if a file is read, as opposed to played specifically.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
|
How to I paste text to and from clipboard while preserving the formating. Because when I paste from the clipboar, the text that use to be bol is not, etc...
Say from 1 textbox into another. Or from a textbox into a word document.
Thanks
|
|
|
|
|
|
I got it to copy, my question is that why it still looses format.
Storing Info:
IDataObject d = Clipboard.GetDataObject();
//d.SetData(DataFormats.Rtf, true, richTextBox1.Text);
// d.SetData(DataFormats.Rtf, richTextBox1.Rtf);
Clipboard.SetText(richTextBox1.Text, TextDataFormat.Rtf);
Retriving info:
foreach (Word.Shape bkMark in aDoc.Shapes)
{
if (bkMark.TextFrame.TextRange.Text.Contains("heading"))
{
// bkMark.TextFrame.TextRange.Paste();
bkMark.TextFrame.TextRange.Text = Clipboard.GetText(TextDataFormat.Rtf).ToString();
//Clipboard.GetDataObject().GetData(DataFormats.Text).ToString();
//
//
}
}
|
|
|
|
|
bkMark.TextFrame.TextRange.Text contains plain text by definition, if you want formatted text you'll have to use clipboard pasting.
To have control over what will actually get pasted you'll have to specify that you want RTF. IIRC there's a PasteSpecial (or something similar) where you can tell Word what format to paste.
Regards,
mav
|
|
|
|
|
Hi
I try to use GetPrivateProfileResString to quickly retrive .ini file information but I dont know how to make a declaration....
Does someone know?
busio
|
|
|
|
|
read this article.
http://www.codeproject.com/csharp/cs_ini.asp
Sanjay Sansanwal
www.sansanwal.com
|
|
|
|
|
S Sansanwal wrote:
http://www.codeproject.com/csharp/cs_ini.asp
http://www.codeproject.com/csharp/cs_ini.asp
[^]
This message brought to you by the click-it cops
Best,
Jerry
Contrary to the cliche, genuinely nice guys most often finish first or very near it.--Malcolm Forbes Toasty0.com
|
|
|
|
|
|
Hi,
I have a list view control with Label Edit Style.
When the user presses a key while an item is selected, Editing should start immediately.
I catch the KeyPress notification and enter edit mode, but I also have to set the edit's contents (or send the simulate the key event).
For that, I think I need the Edit control itself. Is this possible?
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist Fold With Us! || Agile Programming | doxygen
|
|
|
|
|
Hi,
I am attempting to connect with MSDE for the first time with V# .NET, so this is probably a simply questions but I would appreciate help.
I have downloaded an SQL frontend called Teratrax which seems to be great?
My problem is getting full access to the SQL tables I have created, I have difficulty understanding the difference between: Database users and Server logins?
The command SqlConnection is giving me problems, what is 'dbo' user and whats the password for it, my tables appear to be owned by this user?
Any help would be greatly appreciated!
Many thanks for your time and may the force be with you! (you'll need it!)
|
|
|
|
|
Dam.NET wrote:
Database users and Server logins?
A server login is anyone that is permitted to log in to the SQL Server. Each server can host multiple databases, so the Database Users are the users permitted to access a particular database. When a database user is created it must know which login the user is accessing the database with.
To create a login in T-SQL use the command sp_addlogin[^]. And to create a database user use sp_grantdbaccess[^]. These links should give you more information.
Dam.NET wrote:
what is 'dbo' user and whats the password for it
The "dbo" is the DataBase Owner. There is no password for it. The "sa" account (System Administrator) is automatically the dbo, as it any user that has the sysadmin role.
As a general rule all objects (tables, views, stored procedures etc.) in the database should be created by a sysadmin user. Users with the db_owner role are permitted also to create objects but they are owned specifically by that user. At the moment I don't want to overload you will lots of information, suffice to say that is is better to have a sysadmin user create all the database object as it can be a real pain in the neck sorting out the security within a database if you allow joe-user to start creating tables, views, stored procedures etc.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
Fantastic, my open command now works, but (sorry!) I am getting the following response from the SQL server?
Here is my code:
SqlConnection sql = new SqlConnection(ConStr);
sql.Open();
string sqlcommand="SELECT * FROM Users;";
SqlCommand mySqlCom=new SqlCommand(sqlcommand,sql);
SqlDataReader sqlreader;
error--> sqlreader=mySqlCom.ExecuteReader();
The error reported is:
SELECT permission denied on object 'Users', database 'brUsers', owner 'dbo'.
I would image these SQL security options could get quiet complex for a medium/large application?
Those links to the Microsoft site are great!!!
Many thanks for your time and may the force be with you! (you'll need it!)
|
|
|
|
|
Just noticed something I find odd?
When you select a table you get a list of users names? the one I created is now in Database users and in Server logins but not within this table list?
How many passwords do you need for SQL????
Secure its more like fort knox!!!
Many thanks for your time and may the force be with you! (you'll need it!)
|
|
|
|
|
OK, OK, Sorry I have now got the login working but I need help with a command?
I did what you said and I can see how they create login and user accounts, Thanks.
The reason it started working for me was I deleted my simple test data table and recreated is specifing my user account instead of the 'odb' which is the default? how can I add user access to a table that is already created?
Thanks again for all this help, I owe you at least a pint!!!
Many thanks for your time and may the force be with you! (you'll need it!)
|
|
|
|
|
Dam.NET wrote:
how can I add user access to a table that is already created?
As you posted this as I was typing my other, longer, reply you should get the answer in there. But just to refresh:
GRANT SELECT ON TableOrViewName TO UserOrGroupName
Dam.NET wrote:
Thanks again for all this help, I owe you at least a pint!!!
Thanks. Cheers!
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
Dam.NET wrote:
How many passwords do you need for SQL????
Each login has one password.
Of course, you can also add Windows users and groups which allows Windows to perform the authentication on behalf of SQL Server. All you would need to do then is log in to windows.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
What this means is that the account you used to log into the SQL Server does not have SELECT permission for the table Users.
The easiest way is to GRANT SELECT ON Users TO PUBLIC
This means that anyone who is a user of your database can see what is in the table, but not alter it. For more information see the SQL Server books-online: GRANT[^]
Dam.NET wrote:
I would image these SQL security options could get quiet complex for a medium/large application?
It can get complex. That is one reason I said in another thread that all objects in the database should be owned by the dbo, unless you have a very very compelling reason not to. Here is an example in narrative form:
Jack, a db_owner (can create database object, but is not a dbo), creates a table and populates it with some interesting data.
Bob, who is a sysadmin (and therefor is a dbo) sees that some of the intersteing data would be useful to others and creates a view to allow access to only part of the table. He grants permission to public on the view.
Jill, a regular user, wants to use the view and performs a "SELECT * FROM BobsViewOfJacksTable", but the security fails for some reason.
Jill checks the security settings and she has the right to use the view. She is confused and emails Bob.
Bob pastes the select statement into his query analyser and gets the rows back he expects. But doesn't understand why Jill doesn't get the same result. He calls Jack, who tries out the view and it works for him too. Everyone is very confused, because the view is accessable to public, and no-one has a specific deny access on it. Eventually, after two days of trying to work this out, Bob changes the owner of the table to dbo and everything works.
The reason: Jack has only granted select permission to members of sysadmin and db_owner to his table. Jill is neither. However, if the table is owned by the same user as the view the second security check doesn't take place. Jill has access to the view, the view is owned by the dbo, therefore anything that the view uses that is also owned by dbo does not need a second security check, anything that is owned by some other user needs an additional security check.
Does this make your head hurt? It makes mine hurt.
The way this works means that, if everything is owned by the dbo, you don't have to grant access directly to your tables. Instead you can protect them behind views and stored procedures, which the users do have permission for.
It is generally a good idea that permissions are scripted, so everything can be reset easily. Also, if you are doing that it is a good idea that any changes are reflected in the script and the script is kept in a source control system to that the history of changes can be seen easily.
I hope all this helps.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
Collin thanks for all your help today!!!!!!!!!!!!
Many thanks for your time and may the force be with you! (you'll need it!)
|
|
|
|