|
Hi,
I searched DevExpress forum. They say that I need to use gridView.GetRowCellValue() method.
I used this code:
private void gridView4_DoubleClick(object sender, EventArgs e)
{
DXMouseEventArgs mouseEvent = e as DXMouseEventArgs;
GridView view = sender as GridView;
GridHitInfo info = view.CalcHitInfo(mouseEvent.Location);
if (info.InRow || info.InRowCell)
{
MessageBox.Show(gridView4.GetRowCellValue(info.RowHandle, "File Name").ToString());
}
}
But I have error in MessageBox.... line.
it says:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
DevExpress.XtraGrid.Views.Base.ColumnView.GetRowCellValue(...) returned null.
|
|
|
|
|
Either your RowHandle or column name is invalid. Use the debugger to find out which, and why.
|
|
|
|
|
|
Not too difficult was it?
|
|
|
|
|
Come on Alex!
You've been here long enough to know that the first thing you reach for with an exception is the debugger!
If fact, why are you testing your code outside the debugger anyway?
Use the debugger and it'll tell you what is null. When you know that, you can backtrack through your code to find out what should have put a value in there, and why it didn't.
Asking us to work it out is a fruitless exercise for all concerned: we have no access to your running code (which you need for run time errors) or your data (which you probably need for grid based control errors).
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hello,
i have an .exe file which is needed to be started initially as SYSTEM user.
This .exe is calling another instance(copy) of itself, but in user context so that interactive actions can be done (in this case showing a Toast Notification).
In Visual Studio 2017 i used StartAsCurrentUser.exe (GitHub - clreinki/StartAsCurrentUser: A simple EXE to utilize the functionality found in https://github.com/murrayju/CreateProcessAsUser to launch another EXE as currently logged in user[^]. And it worked well. Both processes had access to Registry/HKLM.
Now i had to switch to Visual Studio 2019, and it does not work anymore.
If the second process (in interactive mode, startet by StartAsCurrentUser.exe) tries to write a key in the Registry (HKLM), i get the error "Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\RSMGMT\Apps\TestSystemUser' is denied.
Do you have an idea how the first instance of my program can start itself as a second instance from SYSTEM context in user/interactive mode without loosing access to Registry/HKLM ?
Maybe there is an alternative to Registry/HKLM? I just want to share data between the system process and user/interactive process, both need to have read/write access to a common data basis.
I'm new to C#, so i have no idea about alternatives.
Thank you very much!
Best regards
Emanuel
|
|
|
|
|
AFAIK, to write to HKLM one has to have Admin rights.
|
|
|
|
|
The version of Visual Studio being used has nothing to do with this at all. It's just a heavy-weight editor and debugger.
Normal users do not have the ability to write to anywhere in HKLM by default. In order to open that up (NOT RECOMMENDED!!) you have to change the permissions on the keys you want your users to write to to give them (and therefore the code they launch) that ability.
A better option would be to write data to a file in a folder under %ALLUSERSPROFILE%.
|
|
|
|
|
Thank you!
I decided to solve it with an ini File.
A bit old school but it works fine.
|
|
|
|
|
Just be careful where you put it: if it's in the EXE folder, then it's very likely to work in development, but fail in production - then it'll be under the Program Files folder, and that also need elevated access to modify as it's write protected to reduce virus activity.
Have a look here: Where Should I Store My Data?[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I wondered if there is a possibility to listen to two or more MP3's at the same time and thus mixing them to the audio output, and also handle their volume apart. I saw an application such as Virtual DJ, and I would like to write a C# Winforms application but with very basic possibilities, mixing 2-3 mp3 files, handle their volume separately, and if possible listen to the headphones separately (pre-listening) while another audio file is playing. I looked for code here and there, but the only thing I found was mixing mp3 files and save them to a new file without listening....
|
|
|
|
|
You can have multiple "media elements" playing at the same time; each with their own music source and settings. Beyond that, it's up to you, your equipment, and the app.
"Pre-listening" implies "saving" / buffering. Why is "creating a new file" an issue? It's temporary; and I doubt "pre-listening" means the whole thing (which overlaps with other activities ... and that's why you probably need multiple machines too).
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Thank you Gerry. Creating a new file, temporary, is not directly an issue, it is not a goal on itself. What I want to do is, when one audio file is playing using the output, I would like to pre-listen to another one for instance in the headphones, just like DJ's do.
I wonder if I should give NAudio a try.
|
|
|
|
|
I use this code in a button to save data into a SQLite file:
string conString = @"URI=file:" + Application.StartupPath + "\\DataBase.db";
SQLiteConnection con = new SQLiteConnection(conString);
SQLiteCommand cmd = new SQLiteCommand(con);
con.Open();
try
{
cmd.CommandText = "INSERT INTO FileInfo(EqpCode, EqpName, FileName) VALUES(@EqpCode, @EqpName, @FileName)";
for (int i = 0; i < myTable02.Rows.Count; i++)
{
string EqpCode = myTable02.Rows[i][0].ToString();
string EqpName = myTable02.Rows[i][1].ToString();
string FileName = myTable02.Rows[i][2].ToString();
cmd.Parameters.AddWithValue(@EqpCode, EqpCode);
cmd.Parameters.AddWithValue(@EqpName, EqpName);
cmd.Parameters.AddWithValue(@FileName, FileName);
cmd.ExecuteNonQuery();
}
con.Close();
}
catch (Exception)
{
throw;
}
The error is thrown in cmd.ExecuteNonQuery() line:
System.Data.SQLite.SQLiteException: 'unknown error
Insufficient parameters supplied to the command'
Please help me.
|
|
|
|
|
cmd.Parameters.AddWithValue(@EqpCode, EqpCode);
cmd.Parameters.AddWithValue(@EqpName, EqpName);
cmd.Parameters.AddWithValue(@FileName, FileName);
You need to enclose the parameter names in quotes. They are the strings that identify which parameter they go to in the SQL statement.
cmd.Parameters.AddWithValue("@EqpCode", EqpCode);
cmd.Parameters.AddWithValue("@EqpName", EqpName);
cmd.Parameters.AddWithValue("@FileName", FileName);
|
|
|
|
|
Look at your code.
Instead of inserting a new row each time, you are adding subsequent rows to the existing parameters set by the previous iteration.
So the first row passes 3 pieces of data, the second passes 6, the third 9, and so on ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hi,
I use this:
string[]my_array = Directory.GetFiles(@"Resources\PDFs", "*.pdf");
But, it represents the full path and file name. I want to have only the file names. How can I achieve it?
|
|
|
|
|
Try:
string[] filesWithPath = Directory.GetFiles(@"Resources\PDFs", "*.pdf");
string[] filesWithoutPath = filesWithPath.Select(f => Path.GetFileName(f)).ToArray();
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Solved. Thanks.
modified 5-Jul-21 11:01am.
|
|
|
|
|
I was just going to say:
"It doesn't work" is probably the most useless problem report we get - and we get it a lot. It tells us nothing about what is happening, or when it happens.
So tell us what it is doing that you didn't expect, or not doing that you did.
Tell us what you did to get it to happen.
Tell us any error messages.
But you should know that by now ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Thank you. It worked. It was my fault. Excuse me.
|
|
|
|
|
No problem!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I want to update an existing XML file in DropBox without uploading and replacing a new file. Is it possible using DropBox API?
|
|
|
|
|
After a quick look at the documentation for the API, found here[^], no, you can't.
|
|
|
|
|
Hi
I want to add Label and Farme controls in a way that Label's text is placed inside the Frame and the Frame size is changed based on text lenght. Actually, I want to add this XAML code by clicking a button:
<StackLayout x:Name="MyStack">
<Frame BackgroundColor="GreenYellow" CornerRadius="5" Padding="5">
<Label Text="Just For Test" FontAttributes="Bold" FontSize="Medium" />
</Frame>
</StackLayout>
between these code:
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MReport.TabbedMainPage">
<ContentPage Title="New Report" IconImageSource="NewReport.png" BackgroundImageSource="blue_windows.jpg">
<StackLayout Margin="5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="10*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ScrollView>
<StackLayout x:Name="MyStack">
</StackLayout>
</ScrollView>
<Button Grid.Row="1" Text="Add New Item" Clicked="Button_Clicked" />
</Grid>
<Button Grid.Row="1" Text="Send" />
</StackLayout>
</ContentPage>
<ContentPage Title="Report History" IconImageSource="History.png" BackgroundImageSource="blue_windows.jpg" />
<ContentPage Title="Messages" IconImageSource="Message.png" BackgroundImageSource="blue_windows.jpg"/>
</TabbedPage>
I tried this:
private async void Button_Clicked(object sender, EventArgs e)
{
MyStack.Children.Add(new Frame { CornerRadius = 5, BackgroundColor = Color.Azure});
MyStack.Children.Add(new Label { Text = time_text[0].ToString() });
MyStack.Children.Add(new Label { Text = time_text[1].ToString(), FontAttributes = FontAttributes.Bold, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) });
}
But it cannot add text inside the Frame.
Please help me.
modified 1-Jul-21 12:51pm.
|
|
|
|